springboot - Linux下原本正常的文件上传突然失败

关键词:

springboot文件上传失败

背景:

某项目在部署到云服务器后,运行测试时,文件上传功能正常。过来几天(具体几天忘了)后,文件上传突然失败。查看日志后,错误提示如下:

ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/blogback].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [/blogback] threw exce
ption [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.84655
30737475240398.8083/work/Tomcat/localhost/blogback] is not valid] with root cause
java.io.IOException: The temporary upload location [/tmp/tomcat.8465530737475240398.8083/work/Tomcat/localhost/blogback] is not valid

解决方案:

修改springboot的配置文件

文章目的:

设置springboot中Tomcat的base目录

正文:

在springboot项目的配置文件(application.properties或者application.yml)文件中,添加如下配置:

server.tomcat.basedir = .

相关推荐:

SpringBoot配置属性之Serverhttps://www.jianshu.com/p/bba289149b04

springboot项目文件上传失败https://blog.csdn.net/qq_30095631/article/details/103671082

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章