title: Starting asynchronous task via Spring TaskScheduler
body: <p>I need to execute a task at 7.05am but I am getting an error.
  This is the Controller I created.</p>
  
  <pre><code>@Service("myCtr")
  public class MyController {
  
      @Autowired
      private TaskScheduler scheduler;
  
      @Async
      public void executeTaskT() {
          scheduler.schedule(new MyWorker(), 
                             new CronTrigger("5 7 * * *"));
          }
  }
  </code></pre>
  
  <p>MyWorker is implementing Runnable simply this way:</p>
  
  <pre><code>    [...]
      @Override
      public void run() {
          doWork();
      }
  
      private void doWork() { [...]
  </code></pre>
  
  <p>My scheduler configuration file is imported by the web-application-config.xml:</p>
  
  <pre><code>&lt;beans  xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"&gt;
  
  &lt;bean id="TaskScheduler"
  class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler"&gt;
      &lt;property name="waitForTasksToCompleteOnShutdown" value="true" /&gt;
      &lt;property name="poolSize" value="1000" /&gt;
  &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyCtr': Injection 
  of autowired dependencies failed; nested exception is   
  org.springframework.beans.factory.BeanCreationException: Could not autowire field: private  
  org.springframework.scheduling.TaskScheduler [...].MyController.scheduler; nested 
  exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type 
  [org.springframework.scheduling.TaskScheduler] found for dependency: expected at least 1 bean which 
  qualifies as autowire candidate for this dependency. Dependency annotations: 
  {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  [...]
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private   
  org.springframework.scheduling.TaskScheduler [...].MyController.scheduler; nested 
  exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type 
  [org.springframework.scheduling.TaskScheduler] found for dependency: expected at least 1 bean which 
  qualifies as autowire candidate for this dependency. Dependency annotations: 
  {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  [...]
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type 
  [org.springframework.scheduling.TaskScheduler] found for dependency: expected at least 1 bean which 
  qualifies as autowire candidate for this dependency. Dependency annotations: 
  {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  </code></pre>