Reputation: 1547
We have a maven-managed spring-boot application that we now need to deploy in tomcat using a WAR file. During development, we used maven to start an embedded tomcat with the command:
mvn -D"-classpath %classpath package.path.App" -D"exec.executable=java" process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
I can build a war file by running mvn war:war
, but if I try to deploy the resulting war, an error is produced:
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext
...
Caused by: java.lang.IllegalStateException: No SpringApplication sources have been defined. Either override the configure method or add an @Configuration annotation
I tried adding a mainClass
directive to the maven-war-plugin
's configuration, but to no avail.
Upvotes: 3
Views: 1658
Reputation: 1547
I managed to build a war following dunni's advice.
Basically, I needed to add a @SpringBootApplication
annotation on the class extending SpringBootServletInitializer
, and override its configure
method.
So the diff of my code is like:
+@SpringBootApplication
public class WebAppInitializer extends SpringBootServletInitializer {
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(App.class);
+ }
I still have an error but only after spring starts, but I will ask about that in a different question.
Upvotes: 1