1. springcloud微服务中文件上传服务报临时文件错误:The temporary upload location....

问题

springcloud微服务网关:gateway;
新建的文件上传服务注册到网关上,文件上传经常失败:
1. springcloud微服务中文件上传服务报临时文件错误:The temporary upload location...._第1张图片

原因

  1. springboot的应用服务在启动时,会在操作系统的/tmp目录下生成一个Tomcat.*的文件目录,用于java.io.tmpdir文件流操作;

  2. 程序对文件的操作时:会生成临时文件,暂存在临时文件中;Linux系统的 tmpwatch 命令会删除10天未使用的临时文件;长时间不进行上传操作,导致/tmp下面的tomcat临时文件目录被删除,且删除的文件不可恢复,上传文件时获取不到文件目录,导致报错

解决方案

  1. gateway网关配置文件新增配置,手动设置文件上传临时目录,防止删除
server.tomcat.basedir = /data/temp

1. springcloud微服务中文件上传服务报临时文件错误:The temporary upload location...._第2张图片

  1. 重启网关后,可以看到,临时目录已经变化:
    在这里插入图片描述

你可能感兴趣的:(海滩拾bug)