1.扩展健康端点:编写一个类继承AbstarctHealthIndicator,重写其中的doHealthcheck方法,主要代码如下:
@Component
public class ActuatorConfig extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
builder.up().withDetail("status",true);
}
}
2.完全自定义健康端点:访问:localhost:端口号:/autuator/myEndpoint
@Endpoint(id="myEndpoint")
@Component
public class MyEndpoint {
@ReadOperation
public List<Map<String,Object>> health(){
List<Map<String,Object>>list=new ArrayList<>();
Map<String,Object>map=new HashMap<>();
map.put("id","0001");
map.put("name", "haha");
list.add(map);
return list;
}
}