问题
- spring-boot项目使用内置的tomcat启动时,默认在linux /tmp目录创建工作目录;
- centos默认一定时间删除/tmp目录下的内容
解决
- 方案一 更改centos不删除/tmp目录(或其子目录) 配置文件路径:/usr/lib/tmpfiles.d/tmp.conf 新增配置:
x /tmp/tomcat*
- 方案二 在spring-boot项目application.yml加入tomcat工作目录:
server:
port: 8080
tomcat:
basedir: /data/project/project_name
参考
- https://www.cnblogs.com/kofxxf/p/9907277.html
- https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/reference/html/howto-embedded-web-servers.html#howto-configure-http2-tomcat
- org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat#basedir
本文介绍了解决Spring Boot项目使用内置Tomcat启动时,在Linux环境下/tmp目录下创建的工作目录可能被定时清理的问题。提供了两种解决方案:一是修改CentOS配置使/tmp不被清理;二是直接在application.yml中指定Tomcat的工作目录。


被折叠的 条评论
为什么被折叠?



