2016-12-26 75 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的評論。他正在用同樣的方式指出你 –