springboot 2.0 上传文件时报错,报错信息为:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: 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 (15274832) exceeds the configured maximum (10485760)] with root cause
原因是springboot默认的上传文件大小为1M,如果超过1M就会报此错误,修复方式为在配置文件中添加如下配置:
spring:
servlet:
multipart:
# 支持的最大上传文件大小
max-file-size: 501MB
# 支持的最大请求大小
max-request-size: 501MB