美文网首页
springboot 2.1.0 上传文件太大报错Maximum

springboot 2.1.0 上传文件太大报错Maximum

作者: 安易学车 | 来源:发表于2021-03-22 10:03 被阅读0次

1、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)

2、解决方案:

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;必须打开,放开限制

3.查看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代表不限制

4.springboot 设置请求大小限制

在application.properties配置:

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

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

相关文章

网友评论

      本文标题:springboot 2.1.0 上传文件太大报错Maximum

      本文链接:https://www.haomeiwen.com/subject/hefzcltx.html