https://blog.csdn.net/fxj0720/article/details/80255651
https://www.freesion.com/article/9245162331/
实际解决这个问题是在站点的bootstrap.yml上添加如下配置
spring:
servlet:
multipart:
enabled: true
max-file-size: 5Mb
max-request-size: 5Mb
---------------------------------------------
以下是粘贴复制
---------------------------------------------
org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (11963927) exceeds the configured maximum (10485760)
项目使用的是Spring Boot + Spring Cloud,上传附件报超出自带tomacat限制大小(默认1M)
解决办法:
(1)在配置文件(application.properties)加入如下代码
maxFileSize 单个数据大小
maxRequestSize 是总数据大小
(2)把如下代码放在启动类上,并在类上加入@Configuration
-----------------------------------------------------------------------
springboot项目在上传较大文件时报错:
Maximum upload size exceeded;org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.
报错的原因是:springBoot项目自带的tomcat对上传的文件大小有默认的限制,SpringBoot官方文档中展示:每个文件的配置最大为1Mb,单次请求的文件的总数不能大于10Mb。
知道了是tomcat的默认设置限制了上传的文件大小,那我们只需要改变默认设置即可。
有两点要注意:
(1)这里“10MB”不能写成“10Mb”,否则会报另一个错,如下:
(2)SpringBoot的版本不同,这两个配置语句也不一样,具体版本对应如下:
multipart.maxFileSize
spring.http.multipart.maxFileSize
spring.servlet.multipart.maxFileSize
原文:https://www.cnblogs.com/linus-tan/p/14137089.html