springboot 项目上传大文件报错如下:
org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (96439104) exceeds the configured maximum (10485760)
解决方法:
1.第一种方法:
在application.yml文件中配置,参考:http://yayihouse.com/yayishuwu/chapter/2550
2.第二种方法
在启动类里面加下下面的方法,改成你要设置的文件大小
@EnableScheduling
@SpringBootApplication
public class XinshaiApplication {
public static void main(String[] args) {
SpringApplication.run(XinshaiApplication.class, args);
}
/**
* 文件上传配置
* @return4r
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//单个文件最大
factory.setMaxFileSize("200MB"); //KB,MB
/// 设置总上传数据总大小
factory.setMaxRequestSize("200MB");
return factory.createMultipartConfig();
}
}