Maximum upload size exceeded;nested exception is java.lang.IllegalStateException

报错如下:最近测试文件上传遇到以下问题

        Resolved [org.springframework.web.multipart.MaxUploadSizeExceededException: 
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.]

原因:

        springboot文件上传报错,因为文件大小超过限制,需要配置允许上传的文件的大小。
因为 springboot 默认单个文件上传大小是1MB,默认多个文件上传总大小是10MB。

解决

在 application.yml 文件中设置上传文件的大小

spring:
  servlet:
    multipart:
      max-file-size: 10MB     #单个文件最大限制
      max-request-size: 50MB  #多个文件最大限制

网关解决方法:

注意:这里的路径一定要选择:这个路径不然会报错,我这里检查了两天的代码!!! 

猜你喜欢

转载自blog.csdn.net/Relievedz/article/details/129156063