查看源码如下:
org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration 可以看见调用了MultipartProperties类的createMultiparConfig()方法
![](/i/l/?n=22&i=blog/1232681/202210/1232681-20221021141135820-1747905552.png)
![](/i/l/?n=22&i=blog/1232681/202210/1232681-20221021141113400-711864615.png)
org.springframework.boot.autoconfigure.web.servlet.MultipartProperties :默认是10MB
解决办法1:@bean
/** * 文件大小限制 */ @Bean public MultipartConfigElement multipartConfigElement() { MultipartConfigFactory factory = new MultipartConfigFactory(); factory.setMaxFileSize(DataSize.ofBytes(1048576*200));//1048567是1Mb factory.setMaxRequestSize(DataSize.ofBytes(1048576*200)); return factory.createMultipartConfig(); }
解决办法2: 配置文件配置:
spring.servlet.multipart.max-request-size=209715201 spring.servlet.multipart.max-file-size=209715202
标签:MultipartProperties,文件大小,spring,boot,factory,servlet From: https://www.cnblogs.com/eason-d/p/16813276.html