问题
- 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