Spring에서 Actuator 패스는 하나로 해야합니다.
그렇지 않으면, 엔드포인트 맵핑 충돌 (Endpoint Mapping Conflict)가 발생하여 에러가 납니다. 스프링은 HTTP 요청이 들어왔을 때 어떤 코드를 실행할지 URL 경로와 Controller 를 1:1 로 맵핑합니다.
그런데 Actuator 패스가 두 개로 설정되어있다면, 어떤 컨트롤러로 실행해야할지 알 수가 없어. 실행시점에 에러를 발생합니다.
Gemini의 더 자세한 설명은 아래에 작성하겠습니다.
핵심 원인: 유일해야 하는 핸들러 매핑 빈(Bean)
Spring Boot는 Actuator 엔드포인트들을 관리하기 위해 WebMvcEndpointHandlerMapping (웹 MVC 환경) 또는 WebFluxEndpointHandlerMapping (웹플럭스 환경)이라는 특별한 빈(Bean)을 단 하나만 생성합니다.
이 핸들러 매핑 빈이 Actuator의 모든 엔드포인트(e.g., /health, /info, /metrics 등)의 기본 경로(base path)를 결정하고 HTTP 요청을 해당 엔드포인트 기능에 연결하는 역할을 합니다.
만약 application.properties 파일과 다른 설정 파일(@Configuration 등)에서 각각 다른 경로를 지정하면, Spring Boot는 이 HandlerMapping 빈을 어떻게 설정해야 할지 혼란을 겪게 되고, 이는 보통 애플리케이션 구동 실패로 이어집니다.
충돌이 발생하는 일반적인 시나리오
application.properties와application.yml중복 설정application.properties에서는/actuator로 설정하고, 실수로 다른application-{profile}.properties(예:application-dev.properties) 파일에서는/manage로 설정하는 경우입니다.application.propertiesProperties
management.endpoints.web.base-path=/actuatorapplication-dev.propertiesProperties
management.endpoints.web.base-path=/manage이 경우
dev프로파일로 실행하면 두 설정이 충돌할 수 있습니다.
properties파일과 Java@Configuration의 충돌application.properties에 경로를 설정하고, 동시에 Java 설정 클래스에서 Actuator 관련 빈을 직접 생성하며 다른 경로를 지정하려고 할 때 발생합니다.application.propertiesProperties
management.endpoints.web.base-path=/actuatorJava 설정 (
@Configuration)Java
@Configuration public class CustomActuatorConfig { // 실수로 Actuator의 경로를 재정의하려는 시도를 하는 경우 // (참고: 이런 방식의 설정은 일반적이지 않으며 충돌을 유발하기 쉽습니다) }