创建REST API端点的最佳方法是什么,该端点可以检查其他应用程序资源的健康,例如数据库,Amazon SQS等。
spring-boot-actuator
为数据源提供健康。
添加执行器后使用/health
API。
这是可用健康指标以及如何创建自定义健康指标的春季启动文档。这是有关安全详细信息的文档,以显示健康指标的完整内容。
我认为您不需要不需要,除非自定义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();
}
}