SpringBoot项目 上传大文件报错the request was rejected because its size exceeds the configured maximum 10485760

在SpringBoot项目中进行文件上传的时间报错:the request was rejected because its size exceeds the configured maximum 10485760。这里是因为springboot默认配置 multipart.max-file-size大小是1M,max-request-size默认大小是10M

解决方法:
在application.yml中添加配置

spring:
  servlet:
    multipart:
      max-file-size: 100MB
      max-request-size: 500MB

这里还有注意事项

1.一定要带上单位(KB,MB,GB等)
2. 这种配置是SpringBoot2.0及之后版本的配置

SpringBoot-1.4:

spring:
  http:
    multipart:
      maxFileSize: 100MB
      maxRequestSize: 500MB
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐