Srikanth Technologies

Deploying Spring MVC Application To Tomcat

In this blog, I show how to deploy a Spring MVC application developed using Spring Boot on Tomcat Server.

Preparing Project For Deployment

I assume we have a Spring MVC application developed using Spring Boot ready to be deployed to Tomcat Server.

Before we deploy our application, we need to prepare our Spring MVC application so that it can run on Tomcat Server as a web application.

Follow the steps below to prepare Spring MVC application for deployment. My demo application is called as books.

Make changes to POM.XML

Change packaging to war in POM.XML file using <packaging> element. Provide final name to your project using <finalName> element. Here is final POM.XML file with changes highlighted. The rest of entries in POM.XML remain the same.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""
		<relativePath />  
	<description>Books Tracker</description>




Make .jar files available.

All JAR files related to Maven dependencies are already included in the project. But if there are any JAR files that are not mentioned in POM.XML and handled by Maven then such files (like Oracle JDBC driver) are to be copied to webapp/WEB-INF/lib folder.

It is important to ensure all JAR file are made available at runtime, otherwise application might fail to start. Maven takes care of copying all required JAR files to webapp/WEB-INF/lib when it is creating WAR file. But JAR file like OJDBC6.JAR, which is Oracle JDBC driver, must be manually copied to webapp/WEB-INF/lib folder.

Make Spring Boot Application Runnable in Web Container

In order to run a Spring Boot Application from traditional WAR deployment, we need to extend SpringBootServletInitializer class in Application Class.

Spring Boot documentation has more information about SpringBootServletInitializer.


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

public class BooksApplication  extends SpringBootServletInitializer {

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


Build WAR file

Once packaging is set to WAR, it is possible to create a WAR file for our project by using the following steps.

Start Tomcat Server

Once books.war file is copied to webapps folder in Tomcat server, just go to bin directory of Tomcat server installation and run startup.bat file.

Tomcat will automatically deploy application by creating books folder and copy all files from .war file into books folder. All .jar files from application are copied into /books/WEB-INF/lib folder in Tomcat's webapps folder, classes into /books/WEB-INF/classes folder etc.

It is possible to monitor the status of application by keeping an eye on console window of Tomcat Server. If no errors are found then application is deployed successfully.


The last step is to start browser and make a request to test whether application is deployed successfully.

In my system I used port number 8888 for tomcat (remember 8080 is default but on machines running Oracle, port 8080 is already occupied). So, here is the URL to accessindex.html that is placed in webapp folder in our application.


The rest of the urls are to be accessed as we did when we ran this application as a standalone application with embedded tomcat. For example, if we need to get list of books then we have to give the following url, assuming list is the URL mapped to a request method in controller.


It is possible to deploy WAR file to any other Servers like Glassfish, Web Logic Server with small changes in the deployment process.