SpringBoot 内嵌 Tomcat 的相关配置

application.properties 的配置,针对 Spring Boot 1.5.8 的版本。

|-----------------------------------|--------------------|--------------|---------------------|
| 配置项 | 解释 | 默认值 | 备注 |
| server.port‌ | 配置应用启动时监听的端口号 | 8080 | |
| server.servlet.context-path | 设置应用的根路径 | / | |
| server.session.timeout | 定义session失效时间 | | 单位:秒 |
| | | | |
| server.tomcat.max-threads | Executor 线程池的最大线程数 | 200 | |
| server.tomcat.min-spare-threads | Executor 线程池的核心线程数 | 25 | |
| server.tomcat.max-connections | 配置服务器接受和处理的最大连接数 | 10000 | 不同版本可能有差异 |
| server.tomcat.accept-count | 指定连接数满后的等待队列长度 | 100 | socket 的 backlog 的值 |
| server.tomcat.connection-timeout | socket 读取超时时间 | 20000毫秒(20秒) | 单位:毫秒,0 表示没有超时 |
| server.tomcat.uri-encoding | 指定Tomcat的URI解码字符编码 | UTF-8 | |
| server.tomcat.max-http-post-size | 限制POST请求的最大表单大小 | 2 MB | -1 无限制 |
| server.tomcat.compression.enabled | 控制是否启用Tomcat响应压缩 | false | |

这些参数对应的 Java 类为org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat,其中定义了Tomcat相关的配置属性‌。可以通过查看该类的源码获取所有支持的属性列表‌。