title: "No matching bean of type found for dependency" after I moved some classes
body: <p>I'm dealing with an application composed of many projects. I moved some classes from a project to another one, but I get some unit tests failures.</p>
  
  <p>The most frequent error is like following:</p>
  
  <pre><code>java.lang.IllegalStateException: Failed to load ApplicationContext
      at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
      [cut]
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'prexStatisticsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.companyname.kernel.package1.dao.StatisticsDao com.companyname.kernel.package2.service.PrexStatisticsService.statisticsDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [it.companyname.kernel.package1.dao.StatisticsDao] 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)}
      [cut]
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.companyname.kernel.package1.dao.StatisticsDao com.companyname.kernel.package2.service.PrexStatisticsService.statisticsDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [it.companyname.kernel.package1.dao.StatisticsDao] 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$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
      ... 39 more
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [it.companyname.kernel.package1.dao.StatisticsDao] 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.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:952)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:821)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:735)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
      ... 41 more
  </code></pre>
  
  <p>I don't understand what happened, there're only annotated classes, there isn't xml configuration files. Any help, please?</p>
  
  <p><strong>Updated:</strong></p>
  
  <p>I've modified a unit test method, replacing all its content with a single line:</p>
  
  <pre><code>assertEquals(1, 1);
  </code></pre>
  
  <p>And it still fails. I understand now that Spring can't start when I run unit tests, but it can run when I launch the application (I don't know why).</p>