Spring Boot allows developers to replace the default embedded server with another supported server by excluding the existing server dependency and adding the dependency of the desired server. This flexibility enables applications to use Tomcat, Jetty, or Undertow based on performance, deployment, or architectural requirements.
Default Server in Spring Boot
spring-boot-starter-web
As a result, Tomcat starts automatically when the application launches.
How to Switch the Embedded Server?
1. Exclude the current server.
2. Add the new server dependency.
Switching from Tomcat to Jetty
Step 1: Exclude Tomcat
<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>Step 2: Add Jetty
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-jetty
</artifactId>
</dependency>Embedded Jetty
will be used instead of Tomcat.
Switching from Tomcat to Undertow
Step 1: Exclude Tomcat
<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>Step 2: Add Undertow
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-undertow
</artifactId>
</dependency>Spring Boot will automatically configure Undertow during startup.
How It Works Internally
Application Starts
|
Classpath Scanned
|
Tomcat Excluded
|
Jetty/Undertow Detected
|
Auto-Configuration Applied
|
Selected Server Starts
Spring Boot chooses the available server implementation and configures it automatically.
spring-boot-starter-web
Embedded Tomcat Starts
spring-boot-starter-jetty
Embedded Jetty Starts
The application code remains unchanged.
Why Change the Embedded Server?
Server Options
Tomcat
Jetty
Undertow
Benefits of Embedded Server Switching
Real-World Example
An organization standardizes all microservices on Undertow for lower memory usage.
1. Exclude Tomcat.
2. Add Undertow dependency.
Spring Boot automatically switches servers without requiring changes to controllers, services, or business logic.
A concise interview answer is
To disable the default embedded server in Spring Boot, exclude its dependency from the project configuration. Then add the dependency of the desired server, such as Jetty or Undertow. Spring Boot's auto-configuration mechanism detects the new server on the classpath and automatically configures it without requiring application code changes.
Last updated: 11 November 2026
Previous question: How does Spring Boot decide which embedded server to use if multiple options are available in the classpath?