springboot文件上传大小超过1M,异常
{ "timestamp": "2020-06-04T03:13:35.009+0000", "status": 500, "error": "Internal Server Error", "message": "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.", "path": "/stander/stander/material/local/importMaterial" }
springBoot版本2.1.7
解决版本(启动类无需添加配置)
yml文件配置:
spring:
servlet:
multipart:
max-file-size: 2048MB
max-request-size: 2048MB
(如果不生效,需要考虑系统是否有网关、nginx等也需要配置,)
我这里还需要添加网关配置gateway,文件大小可根据需要配置
spring:
servlet:
multipart:
max-file-size: 2048MB
max-request-size: 2048MB