Creating WAR file from spring boot project Print

  • spring, springboot, spring boot, springboot framework, spring framework, war file
  • 1

Create a WAR File from Your Spring Boot Project


You now need to create a WAR file from your Spring Boot application. Add the following just after the <description> node in your pom.xml.




Remove the embedded Tomcat server by adding the following to your dependencies list:



Finally, enable your application as a servlet by extending your main class with SpringBootServletInitializer:


public class DemoApplication extends SpringBootServletInitializer {


Now, clean and package your application with the following command:

./mvnw clean package

You should see a message like the following:

[INFO] Building war: /home/karl/tst/demo/target/demo-0.0.1-SNAPSHOT.war


Take note where your new .war lives. Upload the .war file to  tomcat/webapps directory and restart tomcat. 

Was this answer helpful?

« Back