SpringBoot默认上传文件大小不能超过1MB,超过之后会报以下异常:
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.
解决方法:
请在配置文件(application.properties/application.yml)中加入如下设置即可
1.5 版本:
spring.http.multipart.maxFileSize=10Mb
spring.http.multipart.maxRequestSize=100Mb