到我的Spring Boot 2.0.0.M6 application.properties
我添加了以下几行:
spring.http.multipart.max-file-size=100MB
spring.http.multipart.max-request-size=100MB
但是当我尝试上传到我的RestController 21MB文件时,它失败并出现以下异常:
Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (21112803) exceeds the configured maximum (10485760)
我在使用Spring Boot打包的Embedded Tomcat上运行我的应用程序。
如何正确配置我的应用程序,以允许文件上传高达100MB?
如the documentation和its appendix所示,正确的属性是spring.servlet.multipart.max-file-size
和spring.servlet.multipart.max-request-size
。