如何在 Spring Boot Actuator 中启用健康状态

Pro*_*mer 5 spring-boot spring-boot-actuator health-check

我必须检查我的服务/应用程序是否有效。

我添加了依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.6.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

并且还尝试添加management.endpoint.health.show-details: alwaysapplication.yml没有帮助。

我尝试访问http://localhost:8080/actuator/healthhttp://localhost:8080/health但返回了 404 错误。

Har*_*rsh 0

默认情况下,Spring boot 为所有执行器端点启用安全性

您可以使用以下属性禁用该功能

management.security.enabled=false  
Run Code Online (Sandbox Code Playgroud)

从今以后,尝试运行应用程序并到达端点

http://localhost:8080/actuator
Run Code Online (Sandbox Code Playgroud)