title: Two Spring Boot projects both with @SpringBootApplication
body: <p>I have a data project and UI project. Both projects are Spring Boot applications. Both projects have the same root package (com.myorg) with a main class annotated with <code>@SpringBootApplication</code>. </p>
  
  <p>Data project's main class is:</p>
  
  <pre><code>package com.myorg;
  @SpringBootApplication
  public class DataApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(DataApplication.class, args);
      }
  
  }
  </code></pre>
  
  <p>The UI project's main class is:</p>
  
  <pre><code>package com.myorg;
  @SpringBootApplication
  public class UiApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(UiApplication .class, args);
      }
  
  }
  </code></pre>
  
  <p>The UI project depends on the data project via the following Gradle dependency:</p>
  
  <pre><code>dependencies {
      compile('com.myorg:data:1.0')
  }
  </code></pre>
  
  <p>If I run the UI application, it runs without issue. However, if I run an integration test within the UI application such as follows:</p>
  
  <pre><code>package com.myorg
  @RunWith(SpringRunner.class)
  @SpringBootTest
  public class UiIntTest {
  
      @Test
      public void contextLoads() {
      }
  
  }
  </code></pre>
  
  <p>The following initialization error occurs: </p>
  
  <p><code>java.lang.IllegalStateException: Found multiple @SpringBootConfiguration annotated classes</code> </p>
  
  <p>In the data project's main class, if I replace <code>@SpringBootApplication</code> with</p>
  
  <pre><code>@Configuration
  @EnableAutoConfiguration
  @ComponentScan({ "com.myorg" })
  </code></pre>
  
  <p>I get the following initialization error when trying to run its integration tests:</p>
  
  <pre><code>java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
  </code></pre>
  
  <p>For example, if I try to run:</p>
  
  <pre><code>package com.myorg
  @RunWith(SpringRunner.class)
  @SpringBootTest
  public class DataIntTest {
  
      @Test
      public void contextLoads() {
      }
  
  }
  </code></pre>
  
  <p>How can I properly configure the data and UI projects?</p>