2015-10-06 30 views
6

HealthIndicatorを実装するクラスを作成しました。これは、ヘルスメソッドをオーバーライドしています。 (詳細なしで、健康)の代わりにスプリングブート状態で詳細が表示されない(詳細情報付き)

{ 
    "status":"UP", 
    "applicationHealth": { 
     "status":"UP" 
    } 
} 

それだけで返します:私はこれが私のhealth -endpoint復帰をしなければならない

Health.down().withDetail("SupportServiceStatus", "UP").build();戻る

{ 
    "status":"UP", 
} 

Javacode(やや簡略化):

@Component 
public class ApplicationHealth implements HealthIndicator { 

    @Override 
    public Health health() { 
    return check(); 
    } 

    private Health check() { 
    return Health.up().withDetail("SupportServiceStatus", supportServiceStatusCode).build(); 
    } 

} 

答えて

9

spring-boot docsによると:

。 。 。デフォルトでは、認証されていないHTTP接続を介して正常性状態のみが公開されます。完全な健康情報が常に公開されることを喜んでいる場合はendpoints.health.sensitivefalseに設定することができます。

ソリューションはapplication.propertiesfalseendpoints.health.sensitiveを設定することです。

application.properties> 1.5.1 application.properties

management.security.enabled=false 
+0

は、春のブートでは機能しませんでした。1.5.1 – cahen

+0

新しいバージョンの回答が – olahell

+0

> 1.4.1と思われます。 1.4.2-RELEASEの管理フラグが必要です – Jontia

5

'endpoints.health.sensitive' 設定するための

endpoints.health.sensitive=false 

は何の違いを作ったん...設定する必要がありました:

+1

これは、1.4.1.RELEASEから1.5 .1リリース(私はちょうどアップグレードし、これをしなければならなかった) – James

1

春のブート2.0.0.RELEASE:

management: 
    endpoint: 
     health: 
     show-details: "ALWAYS" 
関連する問題