Я пытаюсь реализовать привод в весенней загрузке 2.0.2.RELEASE.
Зависимость в pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<scope>compile</scope>
</dependency>
application.properties
management.server.port = 8082
management.endpoint.health.enabled=true
Пользовательский класс проверки здоровья
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;
@Component
public class HealthCheck 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();
}
public int check() {
// Our logic to check health
return 0;
}
}
Когда я нажимаю http://localhost:8082/actuator/health в браузере, я получаю {"status": "UP"}
Я ожидал получить
{
status: "UP",
diskSpace: {
status: "UP",
total: 240721588224,
free: 42078715904,
threshold: 10485760
}
}