I have 2 Spring MVC apps using Spring 4.3. I'll call them app1 and app2.
app1 works fine. I run it from within Intellij using the tomcat7-maven-plugin (jetty:run goal) and all is well. Its WebApplicationInitializer is found and runs just fine.
Now in app2 I include app1 as a war dependency.
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>app1</artifactId>
<type>war</type>
</dependency>
When I run app2, also using tomcat7-maven-plugin (jetty:run goal) I get the following (very well known) message:
INFO: No Spring WebApplicationInitializer types detected on classpath
I have checked my target directory and the app1's classes, including its WebApplicationInitializer are present both in the exploded war directory and the generated war itself. In fact, if I take the war and drop it in a real tomcat7, it loads just fine.
I also tried adding
<context:component-scan base-package="com.mycompany.path_to_initializer"/>
to app2's applicationContext. No dice.
Any idea as to why this doesn't work using the tomcat7 plugin?
Well I never found a real solution to this problem, but luckily the problem went away.
I now have 2 classes, both named AppConfiguration and in the same package, that extend WebMvcConfigurationSupport. One lives in app1, the other in app2.
The app2 version is essentially a copy of the app1 version, substituting 4-5 beans for app2-specific implementation. When I package the application and create the war, the app2 version overwrites the app1 version.
Now that I physically have an AppConfiguration "living" inside app2, tomcat starts no problem; it "finds" the WebApplicationInitializer class (which only exists in app1), and loads the app2 AppConfiguration.
I don't know why you can't have both the WebApplicationInitializer and AppConfiguration in app1. But since this solution works for me, I'm not going to dig any further.
I hope this helps someone out there someday ...