前言
最新使用了springboot框架作为web应用开发,目前已经上生产环境,但是对了每周的代码更新是痛苦的,更加可怕的是之前没有处理好停止服务器的方式,导致更新代码之后偶尔会有一些用户反馈有问题,上去排查大多数结果都是数据丢失造成的,这就迎来了领导的一句话“以后停止服务器的方式做得优雅一点”。
注:
springboot - version: 2.1.0.RELEASE
正文
1.依赖
maven 项目 在 pom.xml 文件中加入 actuator 的依赖:
<!-- springboot监控 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2.配置
springboot配置文件 application.yml 添加如下配置:
management:
endpoint:
shutdown:
enabled: true
endpoints:
web:
exposure:
include: "*"
management.endpoint.shutdown.enabled
这是说是否启动/shutdown端点,默认是false,
management.endpoints.web.exposure.include
这是公开所有端点
我做的时候在网上找了很多,有的说只要设置