报错信息: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.impl.FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.] with root cause
解决方法:
在如果您使用的是Spring Boot,可以在application.properties或application.yml文件中添加以下配置:两个方法选其一,
1、在application.properties中
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
2、或者在application.yml文件中加上
spring:
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
类似于这样,注意格式