title: Spring test with @DataJpaTest can't autowire class with @Repository (but with interface repository works!)
body: <p>I'm trying to understand why I can't autowire a class repository but I can autowire a interface repository in the <strong>same package</strong> for the <strong>same test</strong>. The same repository works as expected when I start the application.</p>
  
  <p>First, the error:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.app.person.repository.PersonRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.support.DefaultPersonbleBeanFactory.raiseNoMatchingBeanFound(DefaultPersonbleBeanFactory.java:1493)
      at org.springframework.beans.factory.support.DefaultPersonbleBeanFactory.doResolveDependency(DefaultPersonbleBeanFactory.java:1104)
      at org.springframework.beans.factory.support.DefaultPersonbleBeanFactory.resolveDependency(DefaultPersonbleBeanFactory.java:1066)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
      ... 28 more
  </code></pre>
  
  <p>I have a very simple example. The test:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @DataJpaTest
  public class PersonRepositoryTest {
  
      @Autowired
      private PersonRepository personRepository; // fail...
  
      @Autowired
      private PersonCrudRepository personCrudRepository; // works!
  
      @Test
      public void findOne() {
      }
  }
  </code></pre>
  
  <p>The repository class:</p>
  
  <pre><code>@Repository
  public class PersonRepository {
      //code
  }
  </code></pre>
  
  <p>The repository interface:</p>
  
  <pre><code>@Repository
  public interface PersonCrudRepository extends CrudRepository&lt;Person, Long&gt; {
  }
  </code></pre>
  
  <p>After a <a href="https://stackoverflow.com/a/48186530/2387977">bad experience with this same error</a>, I'm trying to find some detail in my configuration or test what is responsible for this problem. Another possibility is the <code>@DataJpaTest</code> does not have support for class repositories.</p>