Converting Spring Boot JAR file into Tomcat deployable WAR file

By default, the spring boot applications are bundled into JAR regardless of its nature (web or stand alone app). Sometimes we need to create WAR file and deploy them in the tomcat server. In this article we are going to explore, how the spring boot application change in a way to create tomcat deployable WAR file.

In this application,  maven will be used as the build and dependency management tool.

The first step in producing a deployable war file is to provide a SpringBootServletInitializer subclass and override its configure method. This makes use of Spring Framework’s Servlet 3.0 support and allows you to configure your application when it’s launched by the servlet container. Typically, you update your application’s main class to extend SpringBootServletInitializer:

public class Application extends SpringBootServletInitializer {
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
public static void main(String[] args) throws Exception {, args);

The next step is to update your build configuration so that your project produces a war file rather than a jar file. If you’re using Maven and using spring-boot-starter-parent (which configures Maven’s war plugin for you) all you need to do is to modify pom.xml to change the packaging to war:


The final step in the process is to ensure that the embedded servlet container doesn’t interfere with the servlet container to which the war file will be deployed. To do so, you need to mark the embedded servlet container dependency as provided.


view raw


hosted with ❤ by GitHub

Now you can use the below maven command to build the application.

mvn package


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s