docker健康检查:
Springboot程序部分:
context-path与base-path拼接使用: test: ["CMD", "curl", "-f", "http://localhost:8080/path/api/actuator/health"],
yml
# 服务器配置
server:
port: ${SERVER_PORT:8080}
servlet:
context-path: /path/api
# Actuator 健康检查配置
management:
endpoints:
web:
exposure:
include: health,info
base-path: /actuator
endpoint:
health:
show-details: always
health:
db:
enabled: true
pom依赖:
xml
<!-- Spring Boot Actuator (健康检查) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>