由于新版本的SpringBoot已经弃用了(1.5版本支持)如下,

这种方式,提供了新的 配置方案。
Handling Multipart File Uploads Spring Boot embraces the Servlet 3
javax.servlet.http.PartAPI to support uploading files. By default, Spring Boot configures Spring MVC with a maximum size of 1MB per file and a maximum of 10MB of file data in a single request. You may override these values, the location to which intermediate data is stored (for example, to the/tmpdirectory), and the threshold past which data is flushed to disk by using the properties exposed in theMultipartPropertiesclass. For example, if you want to specify that files be unlimited, set thespring.servlet.multipart.max-file-sizeproperty to-1. The multipart support is helpful when you want to receive multipart encoded file data as a@RequestParam-annotated parameter of typeMultipartFilein a Spring MVC controller handler method. See theMultipartAutoConfigurationsource for more details.

It is recommended to use the container’s built-in support for multipart uploads rather than introducing an additional dependency such as Apache Commons File Upload.
spring.servlet.multipart.max-file-size=200MB
spring.servlet.multipart.max-request-size=200MBpackage cn.arebirth.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import javax.servlet.MultipartConfigElement;
@Configuration
public class FileUploadConfiuration {
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//单个文件大小200mb
factory.setMaxFileSize(DataSize.ofMegabytes(200L));
//设置总上传数据大小10GB
factory.setMaxRequestSize(DataSize.ofGigabytes(10L));
return factory.createMultipartConfig();
}
}