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 @   xiexie0812  阅读(1599)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示