Using Embedded Jetty Server For Spring Boot Application

By default, the spring boot web starter uses an embedded tomcat server. In this article, we will learn how to use an embedded jetty server instead of the default tomcat server in the spring boot application.

Table of Contents

Adding jetty server to the spring application

Create a new spring boot application, and add the below maven dependency.

Also, to enable the jetty server in the spring application, we have to exclude tomcat server dependency in our pom xml file.

Then we have to add spring boot starter jetty dependency as given below.


We can also use the gradle build tool as shown below.

configurations {
    compile.exclude module: "spring-boot-starter-tomcat"
dependencies {

Jetty server spring boot configuration properties

A few of the jetty server configuration properties are shown below.

These are a few of the supported Click here for all available properties list.

server.jetty.accesslog.append=true # Append to log. Z # Timestamp format of the request log.
server.jetty.accesslog.enabled=true # Enable access log.

Jetty server programmatic Customization

We can implement the WebServerFactoryCustomizer interface to customize server configuration.

Below is the programmatic customization of the server port and also the application context path.

public class SpringBootJettyApplication implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
    public static void main(String[] args) {, args);
    public void customize(ConfigurableServletWebServerFactory factory) {

Congratulations!! We have configured an embedded Jetty server for our spring application! ๐Ÿ™‚ Also, letโ€™s run the application. ๐Ÿ™‚

We can be able to see the server is getting started with configured server configuration.

spring boot jetty configuration example


In conclusion, in this article, we learned about how to use an embedded jetty server in the spring application.

Happy coding!! ๐Ÿ™‚ ๐Ÿ™‚