問題描述:在 springboot 項目中,使用feignclient在服務之間傳輸數據,若大小超過10M,控制台或者日志中會提示你類似下面這樣的信息:
Could not read document: UT000020 : Connection terminated as request was larger than 10485769;
nested exception is java.io.Exception:UT000020 : Connection terminated as request was larger than 10485769;
項目 springboot 版本 1.5.2
解決方案:application.properties里添加如下配置
spring.http.multipart.max-file-size=-1
spring.http.multipart.max-request-size=-1
默認值:
private String maxFileSize= "1MB";
private String maxRequestSize = "10MB";
以及下面這個配置:
server.tomcat.max-http-post-size=-1;
這個設置是大小不限制,主要是這個設置。
總結:
- 我們在 使用springboot出現大小限制時,可以選擇修改該默認大小限制
- 更換springboot默認tomcat容器為其他容器,如undertow