Category Archives: Configuration

Spring Boot applications supply a variety of powerful mechanisms for developers to dynamically configure and reconfigure their applications, even while the app is running. In this section we will learn how to configure Spring Boot components (such as the Web server and other components) to achieve your desired configuration.

Configuring HTTP Session timeout in Spring Boot applications

You can configure HTTP Session Timeout for Spring Boot Applications in two ways:

Configuring Session Timeout in

The simplest option is to include in your the parameter server.servlet.session.timeout. For example:


Also note that Tomcat will not allow you to set the timeout any less than 60 seconds.

Configuring Session Timeout Programmatically

Let’s say we want that our HttpSession last only two minutes. To make this happen, we can add to our WebConfiguration class an EmbeddedServletContainerCustomizer Bean with the following content:

Continue reading

Configure Spring Boot to use Jetty Server

By default, Spring boot uses Tomcat as embedded Web server. There are, however, other available Web servers in case you need some specific features. In this tutorial we will learn how to use Jetty as Web Server.

Add spring-boot-starter-jetty dependency

You will need to update pom.xml and add dependency for spring-boot-starter-jetty. Also, you will need to exclude default added spring-boot-starter-tomcat dependency as follows:

<?xml version="1.0" encoding="UTF-8"?><project>

If you are using Gradle as build tool, the same result can be achieved using:

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

Configuring Jetty

The Web server can be configured by overriding the default configuration through the file.
####Jetty specific properties########
server.jetty.acceptors= # Number of acceptor threads to use.
server.jetty.max-http-post-size=0 # Maximum size in bytes of the HTTP post or put content.
server.jetty.selectors= # Number of selector threads to use.

Also, you may configure these options programatically using ConfigurableServletWebServerFactory and JettyServletWebServerFactory classes:

  public ConfigurableServletWebServerFactory webServerFactory() {
    JettyServletWebServerFactory factory = new JettyServletWebServerFactory();
    factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notfound.html"));
    return factory;