SpringBoot正确、安全地关闭服务

前言

我们利用远程关闭功能可以实现优雅地关闭指定地服务。

正文

本文依然使用v1.5.8.RELEASE ,讲地是利用actuatorEndpoints实现关闭服务

首先准备一个eureka服务,然后启动他。

然后准备一个eureka客户端服务,客户端的pom除了必要的springboot的web依赖还需要添加依赖如下

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

在eureka客户端服务的application.properties文件开启shutdown endpoint,SpringBoot的endpoints.shutdown.enabled默认是关闭的。

eureka.client.service-url.defaultZone=http://admin:admin@localhost:1111/eureka/
server.port=8762
spring.application.name=eureka-client
#启用shutdown
endpoints.shutdown.enabled=true
#禁用密码验证
endpoints.shutdown.sensitive=false

#如果用的2.x版本的 就用注释的那四行配置
#management.endpoints.shutdown.enabled=true
#management.endpoints.health.enabled=true
#management.endpoints.web.base-path=/
#management.en
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值