sourcecode

Spring Boot - /health 끝점의 위치를 /ping/me로 변경합니다.

codebag 2023. 7. 7. 19:00
반응형

Spring Boot - /health 끝점의 위치를 /ping/me로 변경합니다.

설정합니다.endpoints.health.path에 대한 재산./ping/me그러나 http://localhost:9000/ping/me를 사용하여 끝점에 액세스할 수 없음 http://localhost:9000/health에서만 작동합니다.제가 무엇을 빠뜨리고 있나요?앱 속성 파일의 코드입니다.

#Configuration for Health endpoint
endpoints.health.id=health
endpoints.health.path=/ping/me
endpoints.health.enabled=true
endpoints.health.sensitive=false

#Manage endpoints
management.port=9000
management.health.diskspace.enabled=false

제가 받는 반응은 다음과 같습니다.

{
"timestamp" : 1455736069839,
"status" : 404,
"error" : "Not Found",
"message" : "Not Found",
"path" : "/ping/me"
}

액추에이터는 Spring Boot 2.0.0에서 기술에 구애받지 않게 되었기 때문에 현재 MVC에 연결되어 있지 않습니다.따라서 Spring Boot 2.0.x를 사용하는 경우 다음 구성 속성을 추가하기만 하면 됩니다.

# custom actuator base path: use root mapping `/` instead of default `/actuator/`
management.endpoints.web.base-path=

# override endpoint name for health check: `/health` => `/ping/me`
management.endpoints.web.path-mapping.health=/ping/me

만약 당신이 그것을 무시하지 않는다면.management.endpoints.web.base-path당신의 건강 검진은 다음 장소에서 가능할 것입니다./actuator/ping/me.

속성은 다음과 같습니다.endpoints.*Spring Boot 2.0.0에서 더 이상 사용되지 않습니다.

Spring Boot 2는 아래를 참조하십시오.* https://stackoverflow.com/a/50364513/2193477


MvcEndpoints읽기를 담당합니다.endpoints.{name}.path구성 및 그 안에서.afterPropertiesSet방법:

for (Endpoint<?> endpoint : delegates) {
            if (isGenericEndpoint(endpoint.getClass()) && endpoint.isEnabled()) {
                EndpointMvcAdapter adapter = new EndpointMvcAdapter(endpoint);
                String path = this.applicationContext.getEnvironment()
                        .getProperty("endpoints." + endpoint.getId() + ".path");
                if (path != null) {
                    adapter.setPath(path);
                }
                this.endpoints.add(adapter);
            }
}

설정을 거부합니다.endpoints.health.path,부터isGenericEndpoint(...)돌아오는 중false위해서HealthEndpoint아마도 벌레나 뭐 그런 것 같습니다.

업데이트: 분명히 이것은 버그였고 버전에서 수정되었습니다.사용할 수 있습니다./ping/me이 버전에서는 상태 모니터링 경로로 사용할 수 있습니다.

언급URL : https://stackoverflow.com/questions/35465556/spring-boot-change-the-location-of-the-health-endpoint-to-ping-me

반응형