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

猜你喜欢

转载自blog.csdn.net/wang20y8/article/details/86589593