Maximum upload size exceeded; nested exception is java.lang.IllegalStateException

业务场景:SpringCloud相关项目,大文件上传:

问题一、The field file exceeds its maximum permitted size of 1048576 bytes.

在这里插入图片描述
解决方案:
报错原因:springBoot项目自带的tomcat对上传的文件大小有默认的限制,SpringBoot官方文档中展示:每个文件的配置最大为1Mb,单次请求的文件的总数不能大于10Mb

我们去对应的application.yml文件以及nacos中jeec.yml文件新增如下配置即可:

server:
  port: 9999
  tomcat:
    max-swallow-size: 10000MB
    connectionTimeout: -1
spring:
  servlet:
    multipart:
      enabled: true #是否支持 multipart 上传文件
      file-size-threshold: 0 #支持文件写入磁盘
      max-request-size: 10000MB  #最大支持请求大小
      max-file-size: 10000MB     #最大支持文件大小

问题二、org.apache.catalina.connector.ClientAbortException: java.io.IOException: 您的主机中的软件中止了一个已建立的连接。

解决方案:
报错原因:
1、请求接口的链接时间超过了设置的公共请求时间,增加接口的自定义请求链接时间

/**
 * 【指定 axios的 baseURL】
 * 如果手工指定 baseURL: '/jeecg-boot'
 * 则映射后端域名,通过 vue.config.js
 * @type {*|string}
 */
let apiBaseUrl = window._CONFIG['domianURL'] || "/jeecg-boot";
//console.log("apiBaseUrl= ",apiBaseUrl)
// 创建 axios 实例
const service = axios.create({
  //baseURL: '/jeecg-boot',
  baseURL: apiBaseUrl, // api base_url
  timeout: 9000 // 请求超时时间
})
export function mergeFile(params) {
  return axios({
    url: '/data/tFileInfo/mergeFile',
    method: 'post',
    timeout: 60000,
    params,
  })
}

2、# hystrix 信号量隔离,原先3秒后自动超时。可增加时长设置为300秒。

hystrix:
  enabled: true
  shareSecurityContext: true
  command:
    default:
      execution:
        isolation:
          strategy: SEMAPHORE
          thread:
            timeoutInMilliseconds: 300000
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值