I fail to understand why in the following minimal project my implementation of Spring's WebApplicationInitializer
interface is found when running tests within Eclipse and IntelliJ, but not when using Maven (mvn clean test
).
With Eclipse and IntellIJ I see INFO: Spring WebApplicationInitializers detected on classpath: [com.example.pack.DummyInitializer@26d678a4]
With mvn clean test
I see INFO: No Spring WebApplicationInitializer types detected on classpath
.
In the test I start an Embedded Tomcat:
String pathToWebXML = new File("src/main/webapp/").getAbsolutePath();
tomcat = new Tomcat();
tomcat.setBaseDir("embedded_tomcat");
tomcat.setPort(0);
tomcat.addWebapp("", pathToWebXML);
tomcat.start();
The web.xml
references a ServletContextListener
implementation which creates a new (and empty) AnnotationConfigWebApplicationContext
.
I uploaded the example project to GitHub: https://github.com/C-Otto/webapplicationinitializer