Springboot 内置Tomcat导致文件上传失败
Spring boot内置Tomcat的临时目录被删除导致文件无法上传
[io-11510-exec-3] com.seven.GlobalDefultExceptionHandler : Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.3614207742003090802.11510/work/Tomcat/localhost/ROOT] is not valid org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.3614207742003090802.11510/work/Tomcat/localhost/ROOT] is not valid at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:122) ~[spring-web-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:113) ~[spring-web-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:86) ~[spring-web-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:93) ~[spring-web-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
解决方案:
1.应用重启 2.增加服务配置,自定义baseDir server.tomcat.basedir=/tmp/tomcat 3.配置不删除tmp目录下的Tomcat vim /usr/lib/tmpfiles.d/tmp.conf #添加一行 x /tmp/tomcat.*
人这辈子没法做太多事情,所以每做一件事都要做到精彩绝伦。
因为,这就是我的宿命。人生苦短,你明白吗?
所以这是我为人生做出的选择