Running Spring boot Junit test with XML defined context
<p>I have a Spring boot aplication with an app-context.xml loaded with @ImportResource as following:</p>

<pre><code>@SpringBootApplication
@ImportResource("META-INF/app-context.xml")
public class BootProjApplication {

    public static void main(String[] args) {
        // creates an app context
        SpringApplication.run(BootProjApplication.class, args);
    }


}
</code></pre>

<p>But when I launch the following JUnit test:</p>

<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = BootProjApplication.class)
@WebAppConfiguration
@Transactional
public class UserServiceTest {

    @Autowired
    UserService userService;


    @Test
    public void contextLoads() {

    }

    @Test
    public void testFindById() {

    ...
    }
</code></pre>

<p>I have this error:</p>

<pre><code>java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate...

Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/META-INF/app-context.xml] at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
... 44 common frames omitted
</code></pre>