The temporary upload location [/tmp/tomcat.8099.5171098371604560613/work/Tomcat/localhost/operationManage] is not valid问题原因及解决办法

原理:springboot应用服务在启动(java -jar启动方式)的时候,会在操作系统的/tmp目录下生成一个tomcat*的文件目录,上传的文件先要转换成临时文件保存在这个文件夹下面。

问题原因:如果超过10天没有使用这个目录,Linux会自动删除这个目录(详见 tmp.conf)

cat /usr/lib/tmpfiles.d/tmp.conf

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# See tmpfiles.d(5) for details

# Clear tmp directories separately, to make them easier to override
v /tmp 1777 root root 10d
v /var/tmp 1777 root root 30d

# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*
X /tmp/systemd-private-%b-*/tmp
x /var/tmp/systemd-private-%b-*
X /var/tmp/systemd-private-%b-*/tmp

解决方案:
(1) 重启应用,自动创建目录
(2)配置tmp.conf

vim /usr/lib/tmpfiles.d/tmp.conf

# 添加如下内容
x /tmp/tomcat.*

# 重启服务
systemctl restart systemd-tmpfiles-clean

(3) springboot配置(待补充)

疑问:tmp.conf中x和X的区别。。。

posted @ 2025-06-06 16:51  program_keep  阅读(63)  评论(0)    收藏  举报