[我相信我几乎遵循了Internet上的所有教程,并且阅读了很多SO答案,但我仍然很困惑。]
@Component
public class HealthCheck implements HealthIndicator {
@Override
public Health health() {
return Health.up().build();
}
}
management.endpoints.web.exposure.include: "*"
management.endpoint.health.show-details: ALWAYS
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
id 'org.springframework.boot' version '2.2.0.RELEASE'
@SpringBootApplication
注释(隐式带来@ComponentScan
)。@SpringBootApplication
public class PaymentServiceApplication {
public static void main(String[] args) {
SpringApplication.run(PaymentServiceApplication.class, args);
}
}
我的自定义健康检查必须测试Apache Kafka,但是为了简洁起见,我跳过了详细信息。仍然,调用/actuator/health
端点,我得到相同的默认结果:
{ "status": "UP", "components": { "diskSpace": { "status": "UP", "details": { "total": 250685575168, "free": 99168997376, "threshold": 10485760 } }, "ping": { "status": "UP" } } }
我有什么想念的吗?
我相信几乎所有的Internet教程都遵循该教程,并且阅读了很多SO答案,但我仍然很困惑。 1.一个简单的健康检查@Component公共类HealthCheck实现HealthIndicator {@ ...
我找到了解决方案,但不确定原因。该类确实未注册为bean,并且令人惊讶的是,显式添加基本包属性有助于: