Java/Spring
Spring Endpoint Health 설정
윤성탁
2016. 7. 19. 15:13
구글에 Spring Endpoint라고 검색하면
많은 설정 정보들이 존재하는데
이번에 사용할 기능은 health check만 설정하도록 해본다.
많은 설정 정보들이 존재하는데
이번에 사용할 기능은 health check만 설정하도록 해본다.
application.properties
# springboot에서 제공하는 기능 - 서버 정보를 알수 있음 # http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html endpoints.enabled=false endpoints.health.enabled=true # health 체크시 여러가지 응답 정보가 가는데, status 정보만 노출하도록 설정 endpoints.health.sensitive=true
build.gradle
compile("org.springframework.boot:spring-boot-starter-actuator")- health check를 위한 디펜던시
Health Check
@Component public class HealthCheck implements HealthIndicator { @Override public Health health() { if (check()) { return Health.up().build(); } else { return Health.down().build(); } } private boolean check() { return true; } }