SpringBoot以jar启动The temporary upload location[xxxx]is not valid

Scene restoration:

The new project used SpringBoot2.0 in order to satisfy the operators using the built-in Boss system, and started in the form of a Jar package. The first online test was completely normal. No one has logged in for 10 days after the Spring Festival, and colleagues later responded An error was reported when logging in. Check the log information:

message:Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.5735866935709960907.8010/work/Tomcat/localhost/ROOT] is not valid
Caused by: java.io.IOException: The temporary upload location [/tmp/tomcat.5735866935709960907.8010/work/Tomcat/localhost/ROOT] is not valid

Cause Analysis:

In the linuxsystem, when the springbootapplication service is restarted (the java -jar command starts the service), a tomcat*file directory will be generated in the / tmp directory of the operating system . The uploaded file must be converted into a temporary file and stored in this folder. Since /tmpthe files in the temporary directory are not used for a long time (10 days), they will be automatically deleted by the system mechanism. So if the system has not been interested for a long time, it may cause the above problem.

solution:

  • Manually create the corresponding folder under / tmp (not recommended)
  • Add in the yml configuration file:
server:
  tomcat:
    basedir: /home/saysky/temp
Published 41 original articles · Liked 14 · Visitors 10,000+

Guess you like

Origin blog.csdn.net/Yunwei_Zheng/article/details/104018497