您的位置:首页 > 编程语言 > Java开发

springboot上传大文件报错

2018-03-08 00:14 330 查看
the request was rejected because its size (48376267) exceeds the configured


配置文件已配置以下属性,但报错依然

spring.http.multipart.maxFileSize=1000Mb
spring.http.multipart.maxRequestSize=1000Mb


故使用另一种方法,在启动类中注入:

import javax.servlet.MultipartConfigElement;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, new String[] { "--debug" });
}

/**
* 设置上传文件大小,配置文件属性设置无效
*
* @author 空空dream
* @date 2018年3月8日
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory config = new MultipartConfigFactory();
config.setMaxFileSize("9000MB");
config.setMaxRequestSize("9000MB");
return config.createMultipartConfig();
}
}


继续上传大文件,不再报错。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: