文章目录
- **结果展示**
- actuators (健康监查)
- 1、添加配置
- 2、配置管理
本文介绍了如何安装健康检查,和配置启用健康检查的info和health端点
有问题请私信问题或者评论区,
结果展示
http://127.0.0.1:8080/actuator
javascript">{"_links": {"self": {"href": "http://127.0.0.1:8080/actuator","templated": false},"health": {"href": "http://127.0.0.1:8080/actuator/health","templated": false},"health-path": {"href": "http://127.0.0.1:8080/actuator/health/{*path}","templated": true},"info": {"href": "http://127.0.0.1:8080/actuator/ver","templated": false}}
}
http://127.0.0.1:8080/actuator/health
javascript">{"status": "UP","components": {"db": {"status": "UP","details": {"database": "MySQL","validationQuery": "isValid()"}},"diskSpace": {"status": "UP","details": {"total": 210978394112,"free": 33048862720,"threshold": 10485760,"path": "/build/.","exists": true}},"livenessState": {"status": "UP"},"ping": {"status": "UP"},"readinessState": {"status": "UP"},"redis": {"status": "UP","details": {"version": "6.0.20"}}},"groups": ["liveness","readiness"]
}
http://127.0.0.1:8080/actuator/ver
javascript">{"app": {"name": "you project name","description": "Parent pom providing dependency and plugin management for applications built with Maven","version": "1.0.0","encoding": "UTF-8","java": {"source": "17.0.2","target": "17.0.2"}},"java": {"version": "17.0.2","vendor": {"name": "Oracle Corporation"},"runtime": {"name": "OpenJDK Runtime Environment","version": "17.0.2+8-86"},"jvm": {"name": "OpenJDK 64-Bit Server VM","vendor": "Oracle Corporation","version": "17.0.2+8-86"}},"customInfo": "项目基础信息","build": {"version": "1.0.0","time": "2025-01-14 19:01:50"},"git": {"mode": "SIMPLE"}
}
actuators (健康监查)
健康检查
The spring-boot-actuator module provides all of Spring Boot’s production-ready features. The recommended way to enable the features is to add a dependency on the spring-boot-starter-actuator starter.
1、添加配置
注 要使用actuator时,其当前包管理环境内一定要能加载到spring web包,不然无法创建端点
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>
</dependencies>
或者
dependencies {implementation 'org.springframework.boot:spring-boot-starter-actuator'
}
2、配置管理
# 管理端点配置
management:endpoint:health: # 打开healthshow-details: alwaysshow-components: alwaysendpoints:web:exposure:include: health,infopath-mapping: # 修改info端点路径info: verinfo:env:enabled: truejava:enabled: true# info配置
info:app:name: "@project.artifactId@"description: "@project.description@"version: "@project.version@"encoding: "@project.build.sourceEncoding@"java:source: "@java.version@"target: "@java.version@"
如果pom没有问题直接访问http://127.0.0.1:8080/actuator就可以看到