Deploy a Spring Boot WAR to an external Tomcat Server - Hello World Example | JavaInUse

Deploy a Spring Boot WAR to an Tomcat Server - Hello World Example

In this example we will learn how to to deploy a Spring Boot Application as a WAR to an external tomcat. So we will not be using the embedded tomcat using which we used to deploy the Spring Boot Application as a JAR.

Lets Begin-

In a previous tutorial we had created a simple Spring Boot Web Application named employee-producer, that exposed a REST web service. This was developed to be deployed using JAR packaging.
We will quickly modify this Application to be deployed using WAR packaging. The project we will as follows-
In the pom.xml change the packaging to WAR.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""


		<relativePath /> <!-- lookup parent from repository -->






Next modify the Spring BootStrap class which extends the SpringBootServletInitializer class to initialize the Servlet context required by Tomcat.
package com.javainuse;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
public class SpringBootHelloWorldApplication  extends SpringBootServletInitializer {
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootHelloWorldApplication.class);
	public static void main(String[] args) {, args);
Run maven command - clean install, and a war file gets created in the target folder.

Download Source Code

Download it -
Spring Boot WAR Deployment