首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sprint Boot应用程序关闭

Sprint Boot应用程序关闭
EN

Stack Overflow用户
提问于 2017-08-18 15:59:47
回答 1查看 256关注 0票数 0

我有一个Spring Boot应用程序,它监听JCAPS。这种连接是持久的。当我使用关闭应用程序时

代码语言:javascript
复制
Curl -X POST ip:port//shutdown

应用程序未完全关闭。当我对进程执行grep时,我可以看到PID。所以我试着用

代码语言:javascript
复制
Kill -15 PID

代码语言:javascript
复制
Kill -SIGTERM PID

PID已不存在,但JCAPS主题的订阅仍处于活动状态。因此,当我重新启动应用程序时,我无法使用相同的订阅者名称连接到相同的主题。

请帮助您正确关闭spring boot应用程序。

EN

回答 1

Stack Overflow用户

发布于 2019-09-28 16:42:16

在pom.xml中添加以下依赖项

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>

在application.properties中设置以下属性

代码语言:javascript
复制
management.endpoints.web.exposure.include=*
management.endpoint.shutdown.enabled=true
endpoints.shutdown.enabled=true

然后启动spring-boot应用程序

你想关闭按照curl命令运行的应用程序

curl -X POST localhost:port/actuator/shutdown

参考:https://www.baeldung.com/spring-boot-shutdown

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45751482

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档