What is the default embedded server used in Spring Boot?

What is the default embedded server used in Spring Boot?

A) Jetty
B) Undertow
C) Tomcat
D) WebSphere

Answer:

C) Tomcat

Explanation:

By default, Spring Boot uses Tomcat as its embedded server. This means that when you create a Spring Boot application, it automatically includes an embedded Tomcat server that allows you to run your application as a standalone Java application without the need for an external web server. The embedded Tomcat server handles HTTP requests and serves your web application.

Spring Boot also supports other embedded servers like Jetty and Undertow, which can be used by excluding Tomcat from the dependencies and adding the appropriate server dependency:


<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>

In this example, Tomcat is excluded, and Jetty is added as the embedded server. This flexibility allows developers to choose the server that best fits their application’s needs, but Tomcat remains the default choice for most Spring Boot applications due to its popularity and robust feature set.

Reference links:

Spring Boot Tutorial

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top