title: Injecting the TaskScheduler with Spring
body: <p>Is it possible to inject the <code>TaskScheduler</code> instance created by Spring?</p>
  
  <p>I would like to schedule tasks programatically and for that, I guess I need to access the <code>TaskScheduler</code> but for some reason, it's not found by Spring for autowiring.</p>
  
  <pre><code>@Configuration
  @EnableScheduling
  public class MySpringConfig {
  
  }
  
  @Component
  public class MyClass implements InitializingBean {
  
      @Autowired
      private TaskScheduler taskScheduler;
  
      @Override
      public void afterPropertiesSet() throws Exception {
          ...
      }
  }
  </code></pre>
  
  <p>Any idea?</p>
  
  <p>Thanks!</p>