springboot 2.1.0 上传文件太大报错Maximum upload size exceeded

springboot 2.1.0 上传文件太大报错

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 (216185201) exceeds the configured maximum (104857600)

解决方案:
1.查看Nginx 是否有限制请求数据大小

 server {
        listen       80;
        #server_name  localhost;
	    client_max_body_size 500M;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
	location /test/ {
	    proxy_pass   http://127.0.0.1:8080/test/;
        }
}

其中: client_max_body_size 500M;必须打开,放开限制

2.查看tomcat是否有限制请求数据大小

在D:\Program Files\Apache Software Foundation\Tomcat 8.5\conf\server.xml

 <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               maxPostSize="-1"
               redirectPort="8443" />

maxPostSize 设置请求大小,-1代表不限制

3.springboot 设置请求大小限制

在application.properties配置:
2.x

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

之前的版本

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

max-file-size和max-request-size的区别在于:
max-file-size:单个文件大小限制
max-request-size:一次请求中所有上传文件总大小限制

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值