Spring Boot各个版本修改文件上传大小限制

Springboot上传文件报错信息如下:

Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.

原因是上传文件大小超出默认大小限制1MB。根据SpringBoot版本不同,修改的方式有区别。

Spring boot 1.4

spring.http.multipart.max-file-size=128KB
spring.http.multipart.max-request-size=128KB

Spring boot 2.x

spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB

如果是微服务架构,gateway可能也得修改。

Referrences

1.Uploading Files
2.How to set the max size of upload file

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容