Spring Boot 2.0.0.M6和文件上传超过10 MB

问题描述 投票:4回答:1

到我的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?

spring tomcat spring-boot spring-rest embedded-tomcat-8
1个回答
8
投票

the documentationits appendix所示,正确的属性是spring.servlet.multipart.max-file-sizespring.servlet.multipart.max-request-size

© www.soinside.com 2019 - 2024. All rights reserved.