As a novice with Spring Boot , I need to know the following as I could not find google results in a straight forward manner. What application servers do they really use for deploying those Spring Boot applications in real life? Is Tomcat really used by companies - if so do they achieve it using clustering?
2 Answers
Spring boot has an inbuilt Tomcat server, it's simply run from Java.
The Tomcat is built into the jar, so it's the same in any environment.
Here is a typical spring boot jar, with the tomcat jars shown:
greg@greg-XPS-13-9360:~/work/boot-docker/target$ jar tvf boot-docker-1.0.3.jar | grep tomcat
2293 Mon Jan 30 19:45:14 GMT 2017 BOOT-INF/lib/spring-boot-starter-tomcat-1.5.1.RELEASE.jar
241640 Tue Jan 10 21:03:52 GMT 2017 BOOT-INF/lib/tomcat-embed-websocket-8.5.11.jar
3015953 Tue Jan 10 21:03:50 GMT 2017 BOOT-INF/lib/tomcat-embed-core-8.5.11.jar
239791 Tue Jan 10 21:03:50 GMT 2017 BOOT-INF/lib/tomcat-embed-el-8.5.11.jar
We run our spring boot applications as docker images (complete virtual Unix server) on Redhat Openshift cloud, which is typical.
BTW Tomcat is used commercially and is very reliable.

- 7,565
- 2
- 21
- 24
-
Pardon my ignorance - I have 2 queries that tag along 1) So the real prod system will be fine with JUST being a *nix server with java installed? 2) So in that case do you just run 100s of instances of your Spring boot projects to handle a service ? – Spear A1 Nov 19 '18 at 15:38
-
@Velan yes to point 1, usually they are run in a cloud which will elastically scale, but it would have to be a massive load to require 100s. – Essex Boy Nov 19 '18 at 15:44
-
Thanks for your helpful explanations @EssexBoy – Spear A1 Nov 19 '18 at 17:34
With Spring Boot application, you can generate an application jar which contains Embedded Tomcat. You can run a web application as a normal Java application.
If you still want to deploy your application with Tomcat Server.
First, you need to package a WAR application instead of a JAR. For this, you need to change pom.xml with the following content:
<profiles>
<profile>
<id>war</id>
<properties>
<packaging.type>war</packaging.type>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
</build>
</profile>
</profiles>
Let’s modify the final WAR file name in finalName element. (for my case, output is ROOT.war)
Next, to initialize the Servlet context required by Tomcat by implementing the SpringBootServletInitializer interface:
@SpringBootApplication
public class YourApplication extends SpringBootServletInitializer {
}
Then, execute Maven command package with war profile:
mvn clean package -Pwar

- 3,647
- 3
- 12
- 18