Eureka+SpringBoot2.X版本实现优雅停服

 

在客户端添加如下配置

 

pom依赖 actuator.jar包

  <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
  </dependency>
或者
<dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

application.yml全局配置文件添加如下

management:
  endpoints:
    web:
      exposure:
        include: shutdown #暴漏shutdown端点服务
  endpoint:
    shutdown:
      enabled: true

然后在postman里边用post请求方式,请求如下地址

http://ip:port/actuator/shutdown

 

 

 

官方介绍:

https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

posted @ 2019-12-03 17:23  Arebirth  阅读(776)  评论(0编辑  收藏  举报