How does Spring Boot decide which embedded server to use?

Spring Boot determines which embedded server to use based on the dependencies available on the application's classpath. During startup, Spring Boot's auto-configuration mechanism scans the project dependencies and automatically configures the appropriate server.

Key Points

Example

Suppose a project includes

spring-boot-starter-web

Spring Boot automatically includes

As a result, the application starts with Tomcat without any additional configuration.

Server Selection Process

Application Startup

↓

Classpath Scanning

↓

Check Available Server Dependencies

↓

Apply Auto Configuration

↓

Start Embedded Server

Supported Embedded Servers

Default Behavior

Dependency

spring-boot-starter-web

Result

Using Jetty

Step 1

Exclude Tomcat dependency.

Step 2

Add

spring-boot-starter-jetty

Result

Using Undertow

Step 1

Exclude Tomcat dependency.

Step 2

Add

spring-boot-starter-undertow

Result

How Auto-Configuration Works

Spring Boot uses

Example Conditional Logic

If Tomcat classes exist

Configure Tomcat

Else If Jetty classes exist

Configure Jetty

Else If Undertow classes exist

Configure Undertow

This process happens automatically during application startup.

Why This Is Useful

Real-World Example

Microservices Application

Order Service

Notification Service

Streaming Service

Each service can use the server best suited for its workload.

<!-- Switch from Tomcat (default) to Jetty: exclude one, add the other -->
<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>

// Internally the choice is made with conditions such as:
@ConditionalOnClass({ Servlet.class, Tomcat.class, UpgradeProtocol.class })
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)

Good to Know

Spring Boot 4.0 (November 2025) dropped support for Undertow, because Undertow was not yet compatible with Servlet 6.1. On Spring Boot 4, the embedded server choices are Tomcat and Jetty, so mention this if the interviewer asks about Undertow.

Interview Tip

A concise interview answer is: Spring Boot chooses the embedded server by inspecting the dependencies available on the classpath during startup. If Tomcat is present, it is configured by default. If Tomcat is excluded and Jetty or Undertow dependencies are added, Spring Boot automatically configures and starts the available server using its auto-configuration mechanism.

Last updated: 11 November 2026

Previous question: What is Spring Cloud, and how is it useful for building microservices?

Next question: Describe a Spring Boot project where you significantly improved performance. What techniques did you use?

More Spring Boot - Level II interview questions

All Spring Boot - Level II questions