How to Deploy a Spring Boot WAR to Tomcat Server

In previous post we have learn how to create spring boot project . In this example we create jar file. But some we need deploy spring boot project as war file inside tomcat server. there is steps how to create war file of spring boot application.

1. Extends SpringBootServletInitializer

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.SpringApplication;

public class DemoApplication extends SpringBootServletInitializer {

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

protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(DemoApplication.class);

for multiple main class define which main class should start

<!-- The main class to start by executing java -jar -->

2. Update packaging to war pom.xml


3. Marked the embedded servlet container as provided.  inside pom file.


<!-- marked the embedded servlet container as provided -->


now run maven clean install and war file generated inside target folder.

Leave a Reply

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

1 + 5 =