I\'m using Spring Boot for my web application and I\'m trying to configure the maxUploadSize of Spring\'s CommonMultipartResolver. Currently, it seems to be limited by a Spr
for Spring Boot 2.0+ use spring.servlet instead of spring.http
spring.servlet.multipart.max-file-size=30MB
spring.servlet.multipart.max-request-size=30MB
@Bean
MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize("5120MB");
factory.setMaxRequestSize("5120MB");
return factory.createMultipartConfig();
}
Try adding this in the class where you are defining beans.
With spring-boot 1.5.3 you should use the following code in application.yml
spring:
http:
multipart:
max-file-size: 10MB
max-request-size: 10MB
You are making it way to complex.
Just add spring.http.multipart.maxFileSize to your application.properties file and well that is it. No need to use xml or explicitly define a MultipartResolver.
spring.http.multipart.maxFileSize=10MB
This is explained in the section about file uploads in the Spring Boot Reference Guide.
For all properties check the MultipartProperties class. The other properties supported are spring.http.multipart.location, spring.http.multipart.maxRequestSize and spring.http.multipart.fileSizeThreshold.
The ClassNotFoundException is due to the fact that Spring Boot uses the default Servlet 3.0 support for file uploads NOT commons-fileupload. So if you want to use that, you would have to explicitly add the dependency for it. And ofcourse the spring.http.multipart.* properties don't work anymore in that case.