At a distant space view post, we chat about codes.

Converting a Spring Boot JAR Application to a WAR extended tutorial

Version: Spring Boot 1.3.5

First, let your spring app main class extends  SpringBootServletInitializer. Override it’s configure method as below.

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

public class YourAppNameApplication extends SpringBootServletInitializer{

	protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
		return application.sources(YourAppNameApplication.class);

	public static void main(String[] args) {, args);


Second, go to your pom.xml maven file. Change the content in the tag named packaging from jar to war.

<project xmlns="" xmlns:xsi=""



One more thing to change in pom.xml. If you’re following the official tutorial on Spring Boot website, you found out that embedded tomcat artifact spring-boot-starter-tomcat is no longer list in the pom.xml file individually. It’s now shipped with the spring-boot-starter-web. My quick workaround is excluding the spring-boot-starter-tomcat within the spring-boot-starter-web package. Put it back as an individual dependency; give a new scope tag as provided.




Now the war file is ready to be built. Do it the way you like. I provide the maven command line way here. Open your shell and navigate to your app’s root directory, where pom.xml lives.

$ mvn clean install

If it shows BUILD SUCCESS, find your war file in the target folder.


Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Converting a Spring Boot JAR Application to a WAR extended tutorial