目标:使用监控Actuator
工具:IDEA–2020.1
学习目标:框架工具集成
本次学习的工程下载链接放到文本最后面
- 运行状态监控Actuator
Spring Boot 的Actuator 提供了运行状态监控的功能, Actuator 的监控数据可以通过REST 、远程shell 和JMX方式获得。在这里先来介绍通过REST方式查看Actuator 的节点的方法。 - 步骤:
- A. POM中新增spring-boot-starter-actuator依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
- B. 配置文件中配置Actuator
management: endpoints: web: exposure: include: "*" endpoint: health: show-details: ALWAYS server: port: 9001 # 指定Actuator对外暴露的REST API接口端口为9001
- C.访问Actuator
- http://localhost:9001/actuator/health 查看运行程序的健康状态
2. http://localhost:9001/actuator/beans 查看运行程序的Bean
- 使用Actuator关闭应该程序
curl -X POST http://localhost:9001/actuator/shutdown (运行此命令必须设置:management.endpoint.shutdown.enabled = true)
**Actuator 是Spring Boot 的一个非常重要的功能, Actuator 为开发人员提供了Spring Boot的运行状态信息,通过Actuator 可以查看程序的运行状态的信息**
Actuator详细介绍可以参考: https://blog.csdn.net/WYA1993/article/details/80540981
评论区