springboot 文件上传大小限制

错误信息

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


方式一:

在yml中加入

spring:  
  #上传限制文件大小
  http: 
   multipart:
   max-file-size: 100MB
   max-request-size: 200MB

(亲测可用)

方式二:

 

有个问题需要注意:如果是走网关的话,需要修改网关配置,不然网关会拦截

zuul中的yml文件在spring加入如下配置

最后附上不同版本直接的配置

Spring Boot 1.4.x 版
multipart:
  enabled: true
  max-file-size: 100MB

Spring Boot 1.5.x - 2.x 版
spring:
  http:
    multipart:
      enabled: true
      max-file-size: 100MB

Spring Boot 2.x 版之后
spring:
  servlet:
    multipart:
      enabled: true
      max-file-size: 100MB

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值