Deploy Spring Boot application on external Tomcat

In this post, we will see how to deploy spring boot application on an external tomcat server. We are going to use Tomcat 7 (i.e apache-tomcat-7.0.94) for this tutorial. It is strongly recommended to follow the same step. Don’t change spring boot version in pom.xml, once you are able to run with 1.x then only go for 2.x spring boot version. We will provide dependency in pom.xml to exclude embedded tomcat so that we can further deploy our war file in external tomcat.

Creating a war file with name BootWarDeployment.war  using maven.

First, we will create war using maven then we will deploy it on external tomcat.

Open eclipse and create maven project, Don’t forget to check ‘Create a simple project (skip)’click on next. Fill all details(GroupId – BootWarDeployment, ArtifactId – BootWarDeployment and name – BootWarDeployment) and click on finish. Keep packaging as the jar.

Modify the pom.xml.


<project xmlns=""

		<relativePath />




					<executable>C:\Program Files\Java\jdk1.8.0_131\bin\javac.exe</executable>


Modify this one where you have installed JDK

                <executable>C:\Program Files\Java\jdk1.8.0_131\bin\javac.exe</executable>


Create package com.bootwar and define all files controller class(, and in this package. We will keep this application simple. Our main purpose is to build(create war) and deploy the application on external Tomcat.

Our directory structure looks as below.

Deploy Spring Boot application on external Tomcat

Initially, we will have nothing in our target folder since I have had already given the build, we have BootWarDeployment.war in the target folder.

package com.bootwar;

public class Book {
	int bookId;
	String bookName;
	String bookPrice;
	public int getBookId() {
		return bookId;
	public void setBookId(int bookId) {
		this.bookId = bookId;
	public String getBookName() {
		return bookName;
	public void setBookName(String bookName) {
		this.bookName = bookName;
	public String getBookPrice() {
		return bookPrice;
	public void setBookPrice(String bookPrice) {
		this.bookPrice = bookPrice;

package com.bootwar;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

public class BookController {
	@RequestMapping(value = "/simpleuri",method = RequestMethod.GET)
    public Book getBook() {
    	Book book = new Book();
    	return book;

package com.bootwar;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
public class SpringMain extends SpringBootServletInitializer{
    public SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringMain.class);
	public static void main(String[] args) {, args);



Since we are deploying war on external tomcat file is not mandatory.


Step 6 – We are good now, let’s create a war file using mvn clean install.

We can create a war file using a different way. Sometimes people use eclipse itself to build the application, also we can use the command prompt.  Here we will use CMD for the build.

Go to the code directory where we have pom.xml. For example currently, I have my code here




Open cmd and run command – mvn clean install

Deploy Spring Boot application on external Tomcat



Deploy the Spring Boot application on external Tomcat.

In target, folder war should be created with name BootWarDeployment.war.

Download Tomcat 7 and extract it.

Copy the war file and paste into the webapps folder.


Go to the bin folder and run the stratup.bat file. Our war file should deploy in tomcat.

Deploy Spring Boot application on external Tomcat



Testing of the example.

Our server has been started. Let’s test the URI which we have defined in the controller.



I have changed my port 8080 to 8081 in server.xml


That’s all about How to Deploy Spring Boot application on external Tomcat. If you face any issue please leave a comment.

Apache Tomcat docs.

Spring boot datasource configuration using tomcat
Deploy Spring boot war in JBoss EAP server.
Jboss 7 EPA datasource configuration using oracle and spring boot.
Deploy multiple war files in JBoss to different port.