2016-12-26 76 views

回答

1

spring-boot-actuator为数据源提供健康。

添加执行器后使用/health API。

以下是可用健康指示器的spring boot documentation以及如何创建自定义健康指示器。这里是documentation on security details显示完整内容的健康指标。

+0

这仅仅是数据源健康检查......我要找的东西,最适合用于检查的许多资源的健康 – Ijaz

+1

你的理解是错的。 Spring Boot执行器提供了许多健康检查,至少对于它集成的所有技术(Mongo,Elastic,Mail,RabbitMQ等等)而言。如果您的技术不在列表中,请添加一个自定义HealthIndictator'不要尝试自己推出,使用和扩展框架提供的内容。 –

+0

谢谢,这很有道理 – Ijaz

0

我觉得你并不需要罢了,除非定制HealthIndicator

@Component 
public class MyHealthIndicator implements HealthIndicator { 

    @Override 
    public Health health() { 
     int errorCode = check(); // perform some specific health check 
     if (errorCode != 0) { 
      return Health.down().withDetail("Error Code", errorCode).build(); 
     } 
     return Health.up().build(); 
    } 

} 
+0

这看起来很不错,并且在谷歌搜索时看到了这一点。我认为应该有一些更好的办法 – Ijaz

+0

不确定在你的关注。请参阅上面Martin的评论。他正在用同样的方式指出你 –