2021-03-01

SpringBoot上传超限:org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the reques...

当局者的胆怯关注

2020.08.08 00:36:05字数 212阅读 905

springboot在上传大文件是报错:

Maximum upload size exceeded;org.apache.tomcat.util.http.fileupload.The field file exceeds its maximum permitted size of 1048576 bytes.

原因是:

springBoot项目自带的tomcat对上传的文件大小有默认的限制,SpringBoot官方文档中展示:每个文件的配置最大为1Mb,单次请求的文件的总数不能大于10Mb。
最常用的方法:在src/main/resources根目录下配置一个application.properties文件。
maxFileSize 单个数据大小

spring.http.multipart.maxFileSize=200MB

maxRequestSize 是总数据大小

spring.http.multipart.maxRequestSize=200MB

但是根据springboot的版本不同,配置语句也不同,很多人就是跟着以前的视频学习,用的版本不一样,所以配置了也无效。
Spring Boot 1.3 版本:

multipart.maxFileSize
multipart.maxRequestSize

Spring Boot 1.4 版本和 1.5 版本:

spring.http.multipart.maxFileSize
spring.http.multipart.maxRequestSize

Spring Boot 2.0 以上版本:

spring.servlet.multipart.maxFileSize
spring.servlet.multipart.maxRequestSize
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值