日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

tomcat服务器文件被清空,SpringBoot内置Tomcat缓存文件目录被意外删除导致异常

發(fā)布時(shí)間:2024/8/5 javascript 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tomcat服务器文件被清空,SpringBoot内置Tomcat缓存文件目录被意外删除导致异常 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在項(xiàng)目中,一般會(huì)將文件臨時(shí)保存到緩存目錄

當(dāng)時(shí)使用

File.createTempFile("tmp", ext,

(File) request.getServletContext().getAttribute(ServletContext.TEMPDIR))

創(chuàng)建臨時(shí)文件時(shí),項(xiàng)目一直運(yùn)行正常,然而有一次報(bào)異常:

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException:

The temporary upload location [/tmp/tomcat.7104877156386249310.8070/work/Tomcat/localhost/ROOT] is not valid

檢查文件目錄,文件確實(shí)不在,檢查代碼,也未發(fā)現(xiàn)問題。實(shí)在不知道原因,只有重啟了服務(wù)器,問題也就不再出現(xiàn)。

今天偶然查看官方文檔,發(fā)現(xiàn)問題所在,也提供了解決方法

If you choose to use Tomcat on CentOS be aware that, by default, a temporary directory is

used to store compiled JSPs, file uploads etc. This directory may be deleted by?tmpwatch

while your application is running leading to failures. To avoid this, you may want to customize

your?tmpwatch?configuration so that?tomcat.*?directories are not deleted, or configure

server.tomcat.basedir?so that embedded Tomcat uses a different location

前往目錄?/etc/cron.daily/ 中,修改?tmpwatch 文件:

#! /bin/sh

flags=-umc

/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix -X ‘/tmp/hsperfdata_*‘ 10d /tmp -X ‘/tmp/tomcat.*‘ 10d /tmp

/usr/sbin/tmpwatch "$flags" 30d /var/tmp

for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do

if [ -d "$d" ]; then

/usr/sbin/tmpwatch "$flags" -f 30d "$d"

fi

done

可以看到添加了一行

-X ‘/tmp/tomcat.*‘ 10d /tmp

原文:http://www.cnblogs.com/wenhui92/p/7109862.html

總結(jié)

以上是生活随笔為你收集整理的tomcat服务器文件被清空,SpringBoot内置Tomcat缓存文件目录被意外删除导致异常的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。