the request was rejected because its size (37524618) exceeds the configured maximum (10485760)

问题bug:

"Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (37524618) exceeds the configured maximum (10485760)",

配置文件中加入:

spring: 
  servlet:
    multipart:
      max-file-size: 50MB
      max-request-size: 50MB

新增一个配置类


@Configuration
public class UploadConfig {


    @Value("${spring.servlet.multipart.max-file-size}")
    private String maxFileSize;
    @Value("${spring.servlet.multipart.max-request-size}")
    private String maxRequestSize;

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //单个文件最大
        //KB,MB
        factory.setMaxFileSize(maxFileSize); 
        /// 设置总上传数据总大小
        factory.setMaxRequestSize(maxRequestSize);
        return factory.createMultipartConfig();
    }
}

你可能感兴趣的:(Bug专栏)