title: Autowiring bean in Spring Boot Scheduler App
body: <p>I am working on a spring boot scheduler app. The scheduling works fine, but I am unable to autowire the business logic bean from another module. I am getting the error "Unable to autowire MyService "</p>
  
  <p>This is a multi module spring boot project.</p>
  
  <p>MyService is an service implementation in another module</p>
  
  <p>Application.java </p>
  
  <pre><code>@SpringBootApplication
  public class Application  {
  
  public static void main(String[] args) {
  
  
      ApplicationContext ctx = new AnnotationConfigApplicationContext(AppScheduler.class);
  }
    }
  </code></pre>
  
  <p>AppScheduler.java</p>
  
  <pre><code>@EnableScheduling
  public class AppScheduler{
  
  @Autowired
  MyService serv;
  
  private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
          "MM/dd/yyyy HH:mm:ss");
  
  @Scheduled(cron = "*/5 * * * * *")
  public void performTaskUsingCron() throws Exception {
  
      serv.test();
  }
  }
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;parent&gt;
      &lt;artifactId&gt;test&lt;/artifactId&gt;
      &lt;groupId&gt;my.service&lt;/groupId&gt;  
   &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;      
  &lt;/parent&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;artifactId&gt;test_BATCH&lt;/artifactId&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;my.service&lt;/groupId&gt;
          &lt;artifactId&gt;test_SERVICE&lt;/artifactId&gt;
          &lt;version&gt;${project.version}&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>