title: Using @Scheduled and @EnableScheduling but gives NoSuchBeanDefinitionException
body: <p>I have followed <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/scheduling.html" rel="nofollow noreferrer">very simple examples</a> online to set up a cron job in Spring yet I keep getting this error in my Tomcat startup log each and every time:</p>
  <pre><code>2015-05-25 00:32:58 DEBUG ScheduledAnnotationBeanPostProcessor:191 - 
  Could not find default TaskScheduler bean org.springframework.beans.factory.NoSuchBeanDefinitionException: No 
  qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
  
  2015-05-25 00:32:58 DEBUG ScheduledAnnotationBeanPostProcessor:202 - Could not    
  find default ScheduledExecutorService bean
  org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying    
  bean of type [org.springframework.scheduling.TaskScheduler] is defined
  </code></pre>
  <p>And the 2 java classes used to implement the cron:</p>
  <ul>
  <li><p>The @Configuration class:</p>
  <pre><code>@Configuration
  @EnableScheduling
  public class ClearTokenStoreCronEnable {    
    final static Logger log =   
    LoggerFactory.getLogger(ClearTokenStoreCronEnable.class);
    private @Autowired TokenStoreRepository tokenStoreRepository; 
  }
  </code></pre>
  </li>
  <li><p>and Cron job class:</p>
  <pre><code>@Service
  public class ClearTokenStoreWorkerService {
  
      final static Logger log = LoggerFactory.getLogger(ClearTokenStoreWorkerService.class);
      private @Autowired TokenStoreRepository tokenStoreRepository;
  
      //@Scheduled(fixedDelay=5000)
      //run daily at midnight
      @Scheduled(cron = &quot;0 0 * * * *&quot;)
      public void tokenStoreTable() {
          log.debug(&quot;tokenstore table truncated - start&quot;);
          tokenStoreRepository.deleteAll();
          log.debug(&quot;tokenstore table truncated - end&quot;);
      }
  }
  </code></pre>
  </li>
  </ul>
  <p>As a side note, the cron job runs at midnight but it also seems to run randomly at other times.  Not sure if this is a bug or my cron expression is wrong:
  <code>@Scheduled(cron = &quot;0 0 * * * *&quot;)</code></p>
  <p><strong>My main concern at this time is why am I getting <code>ScheduledAnnotationBeanPostProcessor</code> errors? It's looking for a TaskScheduler and ScheduledExectorService.</strong>  I just need to fire this once a day.  I am not doing any concurrent processing or where I need multiple threads.  Ultimately are these errors harmful OR do I need to fix them?</p>