springboot2.0上傳檔案大小設定
阿新 • • 發佈:2019-02-18
上傳1.2G大小的視訊,報錯,
在配置檔案中設定:
spring.servlet.multipart.max-file-size=30000Mb spring.servlet.multipart.max-request-size=30000Mb
不管用。後來在啟動類中設定:
@SpringBootApplication
@Configuration
public class ZongheApplication {
public static void main(String[] args) {
// System.out.println("車輛生成條形碼專案執行");
// SpringApplication.run(ZongheApplication.class, args);
System.out.println("綜合專案執行");
SpringApplication.run(ZongheApplication.class, args);
}
/**
* 檔案上傳配置
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//單個檔案最大
factory.setMaxFileSize("30000MB"); //KB,MB
/// 設定總上傳資料總大小
factory.setMaxRequestSize("300000MB");
return factory.createMultipartConfig();
}
} 