Why Spring Boot Embedded Server is so important?

Suresh
2 min readOct 5, 2020

--

Several years back everybody developing the Monolithic application which meaning all modules from Java Project bundled into a single file which is called as WAR file. This War file is deployed into Tomcat Server.
In this case, we need to install the right Java version and Tomcat server in the environment then we should deploy our Web Application. Actually, this process is very easy because we have one Application and one Tomcat server so the management perspective it easy to use.

Now coming to the Microservices world. Nowadays everybody wanted to develop their Java-based application using Microservices Architecture.
What do you mean by Microservice Architecture?
The basic concept of Microservice is, splitting Monolithic application into several services. In this case, each service is a real Web Application which meaning each service needs its own Tomcat Server. Let say in the real world, a project may need 50+ Microservices, and each Microservice needs its own Tomcat server. It is very Tedidous to installing 50 Tomcat servers and manging 50 Tomcat servers. To solve this problem Spring Boot Embedded server is coming into the picture.

If you are using Spring Boot Application, it comes with Tomcat Server as an embedded server so, you don’t have to worry about installing and maintaining the tomcat server for each Microservice you are developing. Spring Boot provides the Production grade Tomcat server as part of the JAR file. Installing and managing the Tomcat server task is totally eliminated by the Embedded Server concept. This is the key feature of the Embedded Server. if you are using the embedded server part of your application, adding Service and removing service is very easy from Microservice Architecture because we don’t have to worry about installing and uninstalling Tomcat Server from the Environment.

Spring Boot Provide three different Embedded server which are
Tomcat Server
Jetty Server
UnderTow

The default Embedded server is Tomcat Server. If you want to change your Tomcat embedded Server to Jetty or UnderTow, you need to add the following configuration in your pom.xml file.
Jetty Server Config for making default embedded server

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

First, you need to exclude the Tomcat embedded server as above (using exclusion tag) then you need to add the Jetty starter Project. The same thing you need to do for UnderTow embedded server.
UnderTow Server Config for making default embedded server


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
I hope this article gives som useful information

ITGARDEN YouTube Chennel for Java-Based Technologies

--

--

Suresh
Suresh

Written by Suresh

I am a Java / J2EE Consultant. Happy to learn. https://pinepad.in/blog/

No responses yet