【发布时间】:2019-10-21 15:40:03
【问题描述】:
@Component
public class CustomHealthIndicator extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
// Use the builder to build the health status details that should be reported.
// If you throw an exception, the status will be DOWN with the exception message.
builder.up()
.withDetail("app", "Alive and Kicking")
.withDetail("error", "Nothing! I'm good.");
}
} 在这里,我注意到默认的健康检查是通过 /health 进行的,当 dataConnection 池缺少可用连接时,我想覆盖上面的内容,我需要返回未准备好的 pod。我还需要检查数据库的运行状况。如何实现?
【问题讨论】:
标签: spring spring-boot spring-data-jpa spring-jdbc spring-boot-actuator