前言
在使用SpringBoot開發接口時,動不動的就發生各種超過默認值的限制,這里總結了下SpringBoot默認限制的設置以及可能會發生的異常,便于問題的排查和快速修改默認值。
配置項 | 配置項說明 | 默認值 | 超過大小后拋出的異常 |
---|---|---|---|
spring.servlet.multipart.max-file-size | Max file size 單個上傳文件大小 | 1MB | org.springframework.web.multipart ?MaxUploadSizeExceededException org.apache.tomcat.util.http.fileupload.impl ?FileSizeLimitExceededException |
spring.servlet.multipart.max-request-size | Max request size. 總上傳文件大小 | 10MB | org.springframework.web.multipart ?MaxUploadSizeExceededException org.apache.tomcat.util.http.fileupload.impl ?SizeLimitExceededException |
server.max-http-header-size | Maximum size of the HTTP message header | 8KB | 此值設置過大可能會造成內存溢出 |
server.tomcat.max-http-form-post-size | Maximum size of the form content in any HTTP post request | 2MB | |
server.tomcat.accept-count | Maximum queue length for incoming connection requests when all possible request processing threads are in use 當所有可能的請求處理線程都在使用中時,傳入連接請求的最大隊列長度 | 100 | |
server.tomcat.max-connections | Maximum number of connections that the server accepts and processes at any given time. Once the limit has been reached, the operating system may still accept connections based on the “acceptCount” property 服務器在任何給定時間接受和處理的最大連接數。一旦達到限制,操作系統仍然可以接受基于“acceptCount”屬性的連接 | 8192 | |
server.tomcat.threads.min-spare | Minimum amount of worker threads 工作線程的最小數量,初始化時創建的線程數 | 10 | |
server.tomcat.threads.max | Maximum amount of worker threads 工作線程的最大數量 | 200 | |
server.tomcat.connection-timeout | Amount of time the connector will wait, after accepting a connection, for the request URI line to be presented 連接器在接受連接后等待顯示請求 URI 行的時間 | 20000 | |
server.tomcat.keep-alive-timeout | Time to wait for another HTTP request before the connection is closed. When not set the connectionTimeout is used. When set to -1 there will be no timeout 在關閉連接之前等待另一個 HTTP 請求的時間。如果未設置,則使用 connectionTimeout。設置為 -1 時不會超時 | 20000 | |
server.tomcat.max-keep-alive-requests | Maximum number of HTTP requests that can be pipelined before the connection is closed. When set to 0 or 1, keep-alive and pipelining are disabled. When set to -1, an unlimited number of pipelined or keep-alive requests are allowed 在連接關閉之前可以進行流水線處理的最大HTTP請求數量。當設置為0或1時,禁用keep-alive和流水線處理。當設置為-1時,允許無限數量的流水線處理或keep-alive請求 | 100 | |
server.tomcat.max-swallow-size | Maximum amount of request body to swallow | 2MB | |
spring.datasource.hikari.maximum-pool-size | hikari線程池最大數量 |