Skip to main content

Run Spring Boot application in Standalone Tomcat Server

How to run Spring Boot application on Tomcat


To deploy a Spring Boot application on existing Tomcat Server, or to bundle it as war file and deploy on Tomcat, following changes are required:
  • Change to war packaging in pom.xml:
<packaging>war
  • Application Main class to extend  SpringBootServletInitializer.
  • Override configure method in this class.
               protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
                       return application.sources(Application.class);
               }
  • Add Tomcat-starter dependency in pom.xml.
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>
  • Run maven install, war will generate in target folder.
  • Deploy on standalone Tomcat Server.
  • Don't forget to add context root to access the services.

I will be happy to help if you run into some issues, while following above steps. Do drop the comments in the comment section.

<<<<<<<<<<<<<<<<<   Happy Coding >>>>>>>>>>>>>>>>>


Comments