Spring Boot 2.0 运行状态监控使用 Actuator /actuator/refresh

springboot的Actuator提供了运行状态监控的功能,可以通过REST、远程Shell和JMX方式来查看。 
   
  使用时倒入spring-boot-starter-actuator的依赖即可。 
  这里说下springboot2.0的配置方法,因为springboot2开始配置项与之前有了些差别: 
  Spring Boot 2.0 运行状态监控使用 Actuator /actuator/refresh_第1张图片 
  之前的配置项为: 
  

management.port=9001
management.security.enabled=false
  • 1
  • 2

这两个属性可以发现已经改变了。

springboot2.0 的配置项为:

#actuator端口 
management.server.port=9001
#修改访问路径  2.0之前默认是/   2.0默认是 /actuator  可以通过这个属性值修改  
management.endpoints.web.base-path=/monitor
#开放所有页面节点  默认只开启了health、info两个节点
management.endpoints.web.exposure.include=*
#显示健康具体信息  默认不会显示详细信息  
management.endpoint.health.show-details=always

配置完成启动项目后就可以通过postman或者直接在预览器输入路径等方式来查看应用的运行状态了。

例如使用postman发送 localhost:9001/monitor/health GET请求 (除了shutdown请求为post,其他的皆为GET请求) 
Spring Boot 2.0 运行状态监控使用 Actuator /actuator/refresh_第2张图片
可以看到redis没有连接成功。

Actuator的api接口: 
Spring Boot 2.0 运行状态监控使用 Actuator /actuator/refresh_第3张图片Spring Boot 2.0 运行状态监控使用 Actuator /actuator/refresh_第4张图片

health的健康指示器: 
Spring Boot 2.0 运行状态监控使用 Actuator /actuator/refresh_第5张图片

官方文档地址:https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

你可能感兴趣的:(Web开发-Spring系列)