SpringBoot生成pid文件
1.引入依赖
<parent> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
2.在启动类中增加一个ApplicationPidFileWriter Listener
@SpringBootApplicationpublic class App {
public static void main(String[] args) {
SpringApplication springApplication= new SpringApplication(App.class);
springApplication.addListeners(new ApplicationPidFileWriter());
springApplication.run(args);
}
}
3.可选填,配置pid文件生成的位置
# 配置pid文件的目录,如果不配的话,默认在根目录下生成application.pid文件 spring.pid.file=/xxx/${spring.application.name}/${spring.application.name}.pid
4.启动程序即可
以上是 SpringBoot生成pid文件 的全部内容, 来源链接: utcz.com/z/514261.html