title: could not autowire field spring-boot
body: <p>Need some help, I am just starting to learn Spring and can't seem to figure out what us wrong:</p>
  
  <p>Application.java - no package</p>
  
  <pre><code>@Configuration
  //@ComponentScan({"com.mapping","com.accesors","com.controllers"}) --Originaly tried this
  @ComponentScan(basePackageClasses={UserDAO.class,Root.class,User.class})
  @EnableAutoConfiguration
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>User.java - package com.mapping</p>
  
  <pre><code>@Entity
  public class User {
  
      @Id
      @GeneratedValue
      private Long id;
      private String userName;
      private String password;
      //accesors
  }
  </code></pre>
  
  <p>UserDAO.java - package com.accesors</p>
  
  <pre><code>@Repository
  public interface UserDAO extends JpaRepository&lt;User, Long&gt; {
  
  }
  </code></pre>
  
  <p>Root.java - package com.controllers</p>
  
  <pre><code>@Controller
  @RequestMapping("/*")
  public class Root {
  
      @Autowired
      UserDAO userDAO;
  
      @RequestMapping("/")
      @ResponseBody
      public String rootAction(@RequestParam(defaultValue="foo") String name){
          List&lt;User&gt; lst = this.userDAO.findAll();
          for(User u : lst){
              System.out.println(u);
          }
          return "hello, " + name;
      }
  
  }
  </code></pre>
  
  <p>And I seem to get the following exeption when I run the project</p>
  
  <p>Stacktrace:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'root': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.accesors.UserDAO com.controllers.Root.userDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.accesors.UserDAO] 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:292)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
      at demo.Application.main(Application.java:14)
  </code></pre>
  
  <p>From what I understand it means that @ComponentScan is not detecting the packages</p>