問(wèn)題記錄:
Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location[/tmp/tomcat.7515932375702737364.8082/work/Tomcat/localhost/] is not valid"
問(wèn)題分析:
這個(gè)問(wèn)題是說(shuō)tomcat上傳文件的臨時(shí)目錄不存在羽利。原因是:Linux系統(tǒng)默認(rèn)會(huì)定時(shí)清理刪除/tmp目錄下的文件目錄蚀瘸。
而SpringBoot使用內(nèi)置tomcat上傳文件時(shí),默認(rèn)會(huì)在linux系統(tǒng)/tmp目錄下創(chuàng)建臨時(shí)文件目錄没酣,所以如果不重新配置臨時(shí)文件目錄轻专,就會(huì)導(dǎo)致springboot項(xiàng)目運(yùn)行一段時(shí)間后出現(xiàn)這個(gè)問(wèn)題忆矛。
問(wèn)題解決:
在配置文件中添加tomcat臨時(shí)文件的存放目錄:
server:
tomcat:
basedir: ${tempDirPath}