当前位置:
凯发k8官方网 >
前端技术
> javascript
>内容正文
javascript
springboot搭建的项目上传文件时提示the temporary upload location ***is not valid -凯发k8官方网
凯发k8官方网
收集整理的这篇文章主要介绍了
springboot搭建的项目上传文件时提示the temporary upload location ***is not valid
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
系统环境centos 7 java 8
springboot内置的tomcat启动时创建临时目录保存上传缓冲文件,但centos会定期清理 默认的临时文件目录(一般都在/tmp下)
凯发k8官方网的解决方案:
一、修改tomcat临时目录
1.1可以采用配置文件的方式(server.tomcat.basedir=/tmp/tomcat);
1.2注入配置bean
@configuration public class multipartconfig {/*** 文件上传临时路径*/@beanmultipartconfigelement multipartconfigelement() {multipartconfigfactory factory = new multipartconfigfactory();string location = system.getproperty("user.dir") "/data/tmp";file tmpfile = new file(location);if (!tmpfile.exists()) {tmpfile.mkdirs();}factory.setlocation(location);return factory.createmultipartconfig();} }二、修改centos的临时目录配置文件,不要清理指定目录
修改 /usr/lib/tmpfiles.d/tmp.conf
# 添加一行
x /tmp/tomcat.*
总结
以上是凯发k8官方网为你收集整理的springboot搭建的项目上传文件时提示the temporary upload location ***is not valid的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: