springboot 大文件上传问题

1. nginx(413 Request Entity Too Large)

     首先:【http|server|location】  下设置:client_max_body_size 100m

     重启nginx:systemctl restart nginx 

    

2. springboot设置   (报错类型:the request was rejected because its size (226000000) exceeds the configured maximum (104857600))

     配置文件添加:

 spring:
servlet:
multipart:
max-request-size: 300MB
max-file-size: 300MB
 server:
tomcat:
max-http-post-size: -1

     启动类添加:

 @Value("${spring.servlet.multipart.max-request-size}")
private String maxFileSize;
@Value("${spring.servlet.multipart.max-file-size}")
private String maxRequestSize;
 @Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
// 单个数据大小
factory.setMaxFileSize(maxFileSize);
// 总上传数据大小
factory.setMaxRequestSize(maxRequestSize);
return factory.createMultipartConfig();
}

 

posted @ 2020-03-12 23:59  静思,随心  阅读(524)  评论(0编辑  收藏  举报