심화/MSA

[MSA] Spring Cloud Config Client 동작 구조 (with Spring Docs)

annovation 2026. 2. 9. 23:22

구조

💡Config Client와 Config Server 연동

 

1) Config Client는 Spring Boot 앱이 Config Server와 통신하는 역할

  • Spring Boot 애플리케이션이 Config Client를 포함하면
    → Config Server에 HTTP로 접근해서 설정 데이터를 받아온다.
  • 받아온 설정 데이터는 Spring Environment에 반영된다.
“A Spring Boot application can take immediate advantage of the Spring Config Server (or other external property sources)… and initializes Spring Environment with remote property sources. (출처)

 

➡️ 즉, Config Client는 원격 중앙 설정 저장소(Config Server) 에서 설정을 가져와 Spring 애플리케이션의 기존 설정 환경에 “로딩”하는 구조

 

2) Config Server 설정 방법

  • Config Server 데이터를 가져오려면 아래와 같은 설정이 기본 형태
spring.config.import=optional:configserver:

 

➡️ 이 설정이 있으면 Config Server를 기본적으로 http://localhost:8888로 연결 시도
→ Optional prefix를 제거하면, 서버 연결 실패 시 바로 예외를 발생시킨다.

 

3) 레거시 방식인 bootstrap 기반 연결도 지원

  • 이 경우 Config Server 주소를 bootstrap.yml에 설정하고 Config Client가 시작하면서 바로 서버와 연결된다.

핵심 구조 요약

Spring Boot App
    │ (spring.cloud.config on classpath)
    ▼
Config Client 자동 구성
    │
    │ 1. spring.config.import 또는 bootstrap 설정으로 Config Server 위치 확인
    ▼
Config Server (HTTP endpoint, default localhost:8888)
    │
    │ 2. Remote config file(e.g., git repo)에서 설정 읽기
    ▼
Config Client
    │
    │ 3. Spring Environment에 remote properties merge
    ▼
ApplicationContext 완성

참고 자료

https://docs.spring.io/spring-cloud-config/reference/client.html?utm_source

 

Spring Cloud Config Client :: Spring Cloud Config

Retry works with the Spring Boot spring.config.import statement and the normal properties work. However, if the import statement is in a profile, such as application-prod.properties, then you need a different way to configure retry. Configuration needs to

docs.spring.io