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

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
posted @ 2022-07-18 11:17  xiexie0812  阅读(1931)  评论(0)    收藏  举报