依赖
<!-- SpringBoot健康检测 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
health配置
如果还想查看info
、metrics
等状态,可以将include: "health"
改为include: "*"
#健康检测
management:
endpoints:
web:
exposure:
include: "health"
#允许跨域访问
cors:
allowed-origins: "*"
allowed-methods: "*"
endpoint:
health:
show-details: always
访问
http://localhost:8888/actuator/health
结果
{
"status":"UP",
"components":{
"db":{
"status":"UP"