스프링 부트 액추에이터 상태 끝점을 사용자 지정 끝점으로 변경
스프링 부트 액추에이터 상태 끝점을 사용자 지정 끝점으로 변경할 수 있습니까?아래와 같은 것입니다.
http://localhost:8080/http/health
로.
http://localhost:8080/myapp/apphealth
이름만 바꾸고 작동기/상태의 응답은 원하지 않았습니다.가능합니까?
네, 가능합니다.
액추에이터 끝점에 대한 경로를 사용자 지정하는 방법은 설명서의 이 섹션에서 정의합니다.
설명서에는 다음이 명시되어 있습니다.
엔드포인트를 다른 경로에 매핑하려는 경우 management.endpoints를 사용할 수 있습니다.web.path-interval 속성.
다음 예제에서는 /actuator/health를 /healthcheck에 재매핑합니다.
application.properties.
경영진, 경영진web.base-path=/
경영진, 경영진web.경로 추적.상태=상태 점검
그래서, 당신의 경우는 다음과 같습니다.
-- application.properties --
management.endpoints.web.base-path=/myapp
management.endpoints.web.path-mapping.health=apphealth
여기에 제시된 답변은 이미 이 질문에 대한 해결책을 제공했습니다.하지만, 저는 액추에이터 상태 끝점을 다른 목적으로 사용자 지정하는 데 어려움을 겪었고, 제 연구 결과를 다른 사람에게도 도움이 되도록 공유하고 싶습니다.아래의 모든 예는 다음을 위한 것입니다.Spring Boot 2.x
.
기본 액추에이터 상태 끝점은 http://localhost:8080/actuator/health입니다.
옵션 1: 변경/actuator/health
같은 사용자 지정 경로가 되는 것/actuator/test
다음을 추가합니다.application.properties
파일
-- application.properties --
management.endpoints.web.path-mapping.health=test
경로: http://localhost:8080/http/test
옵션 2: 변경/actuator/health
같은 사용자 지정 경로가 되는 것/myapp/test
다음을 추가합니다.application.properties
파일
-- application.properties --
management.endpoints.web.base-path=/myapp
management.endpoints.web.path-mapping.health=test
경로: http://localhost:8080/myapp/test
옵션 3: 변경/actuator/health
같은 사용자 지정 경로가 되는 것/health
다음을 추가합니다.application.properties
파일
-- application.properties --
management.endpoints.web.base-path=/
경로: http://localhost:8080/health
옵션 4: 변경/actuator/health
같은 사용자 지정 경로가 되는 것/test
다음을 추가합니다.application.properties
파일
-- application.properties --
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=test
경로: http://localhost:8080/test
옵션 5: 포트 변경8080
포트를 사용자 지정하는 방법8081
다음을 추가합니다.application.properties
파일. 기본 응용 프로그램은 포트에서 실행됩니다.8080
.
-- application.properties --
management.server.port=8081
경로: http://localhost:8081/http/health
언급URL : https://stackoverflow.com/questions/52654763/changing-spring-boot-actuator-health-end-point-to-a-custom-end-point
'sourcecode' 카테고리의 다른 글
Vue TypeScript 프로젝트의 이벤트 유형은 무엇입니까? (0) | 2023.06.28 |
---|---|
SQL이 where 절에서 열 별칭을 인식하지 못합니다. (0) | 2023.06.28 |
Spring-boot에서 정적 웹 콘텐츠를 추가하는 방법 (0) | 2023.06.28 |
날짜를 올바르게 저장하는 방법은? (0) | 2023.06.28 |
SQL Server 데이터베이스의 모든 스키마 목록을 가져오려면 어떻게 합니까? (0) | 2023.06.28 |