我想显示以下健康信息:
{
"status":"UP",
"components": {
"myHealthComposite": {
"status":"UP",
"components": {
"myFirstHealthIndicator": { "status":"UP" },
"mySecondHealthIndicator": { "status":"UP" }
}
}
},
"groups":[]
}
[从最新的Spring Boot Actuator文档中,我应该使用“ HealthIndicator”-接口实现“ myFirstHealthIndactor”和“ mySecondHealthIndicator”,并使用“ CompositeHealthContributor”-接口将它们组合在一起。但是对于“ CompositeHealthContributor”,我需要一个示例,在文档中我找不到对我有用的东西。
有人可以帮我吗?
问候
编辑:
myFirstHealthIndicator
@Component
public class MyFirstHealthIndicator implements HealthIndicator {
@Override
public Health health() {
return Health.up().build();
}
}
mySecondHealthIndicator
@Component
public class MySecondHealthIndicator implements HealthIndicator {
@Override
public Health health() {
return Health.up().build();
}
}
myHealthComposite
@Component
public class MyHealthComposite implements CompositeHealthContributor {
@Override
public HealthContributor getContributor(String name) {
return null;
}
@Override
public Iterator<NamedContributor<HealthContributor>> iterator() {
return null;
}
}
输出期望值的非常简单且硬编码的解决方案。