title: Spring Boot multiple module test Autowiring
body: <p>I have a multiple module project with structure:</p>
  
  <pre><code>app/
    build.gradle
    settings.gradle
    app-web/
      src/main/java/example/
        Application.java
    app-repository/
      src/main/java/example/
        CustomerRepository.java
        Customer.java
      src/test/java/example/
        CustomerRepositoryTest
  </code></pre>
  
  <p>With Application Class: </p>
  
  <pre><code>@SpringBootApplication
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class);
      }
  }
  </code></pre>
  
  <p>With Repository</p>
  
  <pre><code>@Repository
  public interface CustomerRepository extends JpaRepository&lt;Customer, Long&gt; {
  }
  </code></pre>
  
  <p>And Repository Test</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  public class CustomerRepositoryTest {
  
      @Autowired
      private CustomerRepository repository;
  
      @Test
      public void shouldSave() {
          // When
          final Customer saved = repository.save(new Customer());
  
          // Then
          assertThat(saved.getID()).isNotNull();
      }
  }
  </code></pre>
  
  <p>Now when I run this test I get the error: </p>
  
  <blockquote>
    <p>Unable to find a @SpringBootConfiguration, you need to use
    @ContextConfiguration or @SpringBootTest(classes=...) with your test</p>
  </blockquote>
  
  <p>This doesnt appear when I have the Application class in my repository module but I need them to be seperated out. What's the best way to get this to work?</p>
  
  <p>If it helps my Spring dependencies are:</p>
  
  <pre><code>compile("org.springframework.boot:spring-boot-starter-data-jpa")
  compile("com.h2database:h2")
  testCompile("org.springframework.boot:spring-boot-starter-test")
  </code></pre>
  
  <p>Using the plugin <code>org.springframework.boot:spring-boot-gradle-plugin:1.5.8.RELEASE</code></p>