title: How do I import configuration classes in a @DataJpaTest in a SpringBootTest?
body: <p>I have a <strong>SpringBoot Application</strong> and I a config package with</p>
  
  <pre><code>@Configuration
  @EnableJpaAuditing
  public class PersistenceConfig {
  }
  </code></pre>
  
  <p>But the <strong>PersistenceConfig</strong> does not get picked up in a <strong>PersonRepositoryTest</strong></p>
  
  <pre><code>@RunWith( SpringRunner.class )
  @DataJpaTest
  public class PersonRepositoryTest {
  
      // Tests ...
  }
  </code></pre>
  
  <p>However, if I change from <code>@DataJpaTest to @SpringBootTest</code>, PersonRepositoryTest will pick up the config.</p>
  
  <p>My <strong>package structure</strong> is</p>
  
  <pre><code>- main
      - java
          - config
                PersistenceConfig.java
          - domain
                Person.java
          - persistence
                PersonRepository.java
            Application.java // @SpringBootApplication
  
  - test
      - java
          - persistence
                PersonRepositoryTest.java
  </code></pre>
  
  <p>The <a href="https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4" rel="noreferrer">Testing improvements in Spring Boot 1.4</a> suggest to test the persistence layer with @DataJpaTest</p>
  
  <p><strong>Observation:</strong>
  Doing both annotations on the Test class still do not import the config
  @SpringBootTest
  @DataJpaTest</p>
  
  <p><strong>Question 1:</strong>
  When testing the Persistence Layer with @DataJpaTest
  how do I <strong>properly</strong> (best practise way in Spring Boot) import the config package into my Tests?</p>
  
  <p><strong>Question 2:</strong>
  Can it be an acceptable work around using @SpringBootTest? I am aware that @DataJpaTest is also a meta annotation with sensible auto configuration for my database including transaction management. But what If I do not need it?</p>