查看源码如下:
org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration 可以看见调用了MultipartProperties类的createMultiparConfig()方法
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