{
"timestamp": "2020-05-07 18:05:24",
"status": 500,
"error": "Internal Server Error",
"message": "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 (59593838) exceeds the configured maximum (6291456)",
"path": "/rrk-file-center/tPicture/pictures"
}
在网上找了各种解决办法,在yml中添加配置
http:
multipart:
max-file-size: 100MB
max-request-size: 100MB
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
添加配置
@Configuration
public class MultipartConfig {
/**
* 文件上传临时路径
*/
@Bean
MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//String location ="d:/home/localFile/temp";
// String location = tempPath;
String location = System.getProperty("user.dir") + "/data/tmp";
//String location = System.getProperty("user.home") + "/rrk-file/file/tmp";
File tmpFile = new File(location);
if (!tmpFile.exists()) {
tmpFile.mkdirs();
}
factory.setLocation(location);
factory.setMaxFileSize("100MB");
factory.setMaxRequestSize("100MB");
return factory.createMultipartConfig();
}
}
还是不行,最后发现在网关中也配置了文件大小,也需要修改网关中的文件大小限制
servlet:
multipart:
enabled: true
max-file-size: 100MB ##将之前的6M改成了100M
max-request-size: 100MB##将之前的6M改成了100M
终于搞定!