카테고리 없음

[Spring Cloud Config] 1-1. Spring Cloud Config Server: Introduction

noahkim_ 2025. 8. 20. 23:08

0. Introduction

  • 분산 시스템에서 외부 설정을 중앙에서 관리하기 위한 프레임워크
  • ✅ 애플리케이션 설정을 중앙 저장소에 두기 (git)
  • ➡️ Config Server와 Client가 이를 동적으로 가져와 사용

 

구성 요소

구성 요소 역할 비고
Git Backend 설정 파일들이 저장된 중앙 레포지토리
환경/서비스별 파일 관리, 버전 관리 가능
Config Server 중앙에서 설정 파일을 읽어와 제공하는 서버 Git에서 설정을 가져와 REST API로 노출
Config Client 애플리케이션 실행 시 Config Server로부터 설정값을 받아 사용 가져온 값이 Spring Environment / PropertySource에 주입됨

 

예) Git Backend

더보기
application.yml
user-service-dev.yml
user-service-prod.yml
chat-service-dev.yml
price-service-dev.yml

 

장점

장점 설명 특징 / 예
중앙 집중 관리
설정 파일을 한 곳(Git 등)에서 관리
서비스마다 따로 수정할 필요 없음
환경 분리 환경별 설정 파일을 분리 관리 가능 dev / test / prod 등
버전 관리 Git 사용 변경 이력 추적, 이전 버전 복구 가능
언어 독립성
HTTP API로 설정을 제공하므로 
Spring 이외의 애플리케이션에서도 사용 가능

 

1. Spring Cloud Config Server

  • 외부 설정을 HTTP API로 제공하는 서버
  • 설정 값은 yaml, properties 파일 형식으로 제공됨

 

설정) @EnableConfigServer

더보기
@SpringBootApplication
@EnableConfigServer
public class ConfigServer {
    public static void main(String[] args) {
    	SpringApplication.run(ConfigServer.class, args);
    }
}

 

설정) application.properties

더보기
server.port=8888
spring.cloud.config.server.git.uri=file://${user.home}/config-repo
  • spring.cloud.config.server.git.uri: 설정 파일이 저장된 Git Repository 경로 지정 (로컬 git 주소 or 원격 git 주소)

 

 

 

 

출처