Explain the concept of Spring Boot's embedded servlet containers.

Spring Boot's embedded servlet container feature allows a web application to run with an internal web server packaged directly inside the application. This eliminates the need to install, configure, and manage an external application server separately, making deployment and development significantly easier.

Key Points

Example

Traditional Spring Application

Application Code

↓

WAR File

↓

External Tomcat Server

↓

Deploy and Configure

Spring Boot Application

Application Code

↓

Embedded Tomcat

↓

Executable JAR

↓

java -jar app.jar

The application starts immediately with its own web server.

Default Embedded Server

Other Supported Servers

These can replace Tomcat by changing project dependencies.

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(
                Application.class, args);
    }
}

When the application starts

Typical Startup Process

Application Start

↓

Create Spring Context

↓

Initialize Embedded Server

↓

Register Servlets and Filters

↓

Application Ready

Benefits

Configuration Example

server.port=9090

This changes the embedded server port from

8080 → 9090

Additional Configurations

server.servlet.context-path=/api
server.tomcat.max-threads=200

Replacing Embedded Tomcat

Maven Example

Exclude

spring-boot-starter-tomcat

Add

spring-boot-starter-jetty

Spring Boot automatically configures Jetty as the embedded server.

Real-World Example

Microservices Architecture

Each microservice contains

This allows every service to be deployed independently as a standalone executable JAR or Docker container.

Best Practices

Interview Tip

A concise interview answer is: Spring Boot uses embedded servlet containers such as Tomcat, Jetty, or Undertow to package the web server directly inside the application. This allows applications to run as standalone executable JAR files without requiring an external application server, simplifying development, deployment, and scaling.

Last updated: 16 July 2026

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

Next question: How does Spring Boot make DI easier compared to traditional Spring?

More Spring Boot - Level II interview questions

All Spring Boot - Level II questions