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

£神魔★判官ぃ 2024-04-01 19:40 134阅读 0赞

前言

springboot 中文件上传时控制台报错如下,很明显是上传的文件问题,因为上传的文件大小超过了默认限制的限制大小。

因为 springboot 默认单个文件上传大小是1MB,默认多个文件上传总大小是10MB

  1. Resolved [org.springframework.web.multipart.MaxUploadSizeExceededException:
  2. Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException:
  3. The field file exceeds its maximum permitted size of 1048576 bytes.]

请添加图片描述

解决

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

  1. spring:
  2. servlet:
  3. multipart:
  4. max-file-size: 10MB #单个文件最大限制
  5. max-request-size: 50MB #多个文件最大限制

效果

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,134人围观)

还没有评论,来说两句吧...

相关阅读