title: Spring Boot @autowired does not work, classes in different package
body: <p>I have a Spring boot application.  </p>
  
  <p>I get the following error</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'birthdayController': Injection of autowired
    dependencies failed; nested exception is
    org.springframework.beans.factory.BeanCreationException: Could not
    autowire field: private com.esri.birthdays.dao.BirthdayRepository
    com.esri.birthdays.controller.BirthdayController.repository; nested
    exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    qualifying bean of type [com.esri.birthdays.dao.BirthdayRepository]
    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)}
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
          at or</p>
  </blockquote>
  
  <p>Following is code of my Repository class</p>
  
  <pre><code>package com.esri.birthdays.dao;
  import com.esri.birthdays.model.BirthDay;
  public interface BirthdayRepository extends MongoRepository&lt;BirthDay,String&gt; {
      public BirthDay findByFirstName(String firstName);
  }
  </code></pre>
  
  <p>Following is controller.</p>
  
  <pre><code>package com.esri.birthdays.controller;
  @RestController
  public class BirthdayController {
  
      @Autowired
      private BirthdayRepository repository;
  </code></pre>
  
  <p><strong>Works if they are in same package.</strong>  Not sure why</p>