解决org.springframework.web.multipart.MaxUploadSizeExceededException

今天在spring boot2X 里做文件上传遇到了如下错误

org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.
    at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:121) ~[spring-web-5.1.8.RELEASE.jar:5.1.8.RELEASE]

原来是文件大小超出了1M,spring boot 默认为1M

解决方案:

  在 application.properties 添加

spring.servlet.multipart.max-file-size=300MB
spring.servlet.multipart.max-request-size=350MB
原文地址:https://www.cnblogs.com/baby123/p/11244628.html