码上敲享录 > SpringBoot常见问题详解 > springboot上传大文件报错the request was rejected because its size (xx) exceeds the configured maximum (xx)

springboot上传大文件报错the request was rejected because its size (xx) exceeds the configured maximum (xx)

上一章章节目录下一章 2019-09-10已有5851人阅读 评论(0)

springboot 项目上传大文件报错如下:

org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (96439104) exceeds the configured maximum (10485760)


解决方法:

1.第一种方法:

在application.yml文件中配置,参考:http://yayihouse.com/yayishuwu/chapter/2550


2.第二种方法

在启动类里面加下下面的方法,改成你要设置的文件大小

@EnableScheduling

@SpringBootApplication

public class XinshaiApplication {


   public static void main(String[] args) {

       SpringApplication.run(XinshaiApplication.class, args);

   }

   /**

    * 文件上传配置

    * @return4r

    */

   @Bean

   public MultipartConfigElement multipartConfigElement() {

       MultipartConfigFactory factory = new MultipartConfigFactory();

       //单个文件最大

       factory.setMaxFileSize("200MB"); //KB,MB

       /// 设置总上传数据总大小

       factory.setMaxRequestSize("200MB");

       return factory.createMultipartConfig();

   }

}


0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交