SpringBoot2.x series of tutorials (thirty-six) SpringBoot the Tomcat configuration

Spring Boot default is embedded Tomcat Servlet container, all the properties are in ServerProperties about Tomcat configuration class. Meanwhile, the configuration may also be implemented from some interfaces defined inline embedded Tomcat Servlet containers and the like.

About this configuration, there is a lot of information on the Web, but they are based on SpringBoot1.5.x version, not suitable for the most current version. This article will take you look at the latest version.

ServerProperties part of the source code:

@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
public class ServerProperties {
    private Integer port;
    // ...
    public static class Servlet {
        private String contextPath;
        // ...
    }
    public static class Tomcat {
        private int maxThreads = 200;
		private int minSpareThreads = 10;
		// ...
    }
}

As can be seen by the source Servlet containers are configured to "server" as a prefix, and the configurations related to Tomcat "server.tomcat" as a prefix.

application.properties Configuration

Usually only can be configured for specific attributes application.properties configuration file.

Common servlet container configuration is as follows:

server.port = #配置程序端口,默认为8080
server.session-timeout=#用户session过期,以秒为单位
server.context-path= #配置访问路径,默认为/

Common Tomcat configuration is as follows:

server

Guess you like

Origin blog.csdn.net/wo541075754/article/details/104028012
Recommended