1. Spring Cloud Config란 무엇일까?
- 분산 시스템 환경에서 중앙 집중식 구성 관리를 제공하는 프레임워크
- Git, 파일 시스템, JDBC 등 다양한 저장소를 지원
1-2. 주요 기능
- 중앙 집중식 구성 관리: 모든 마이크로서비스의 설정을 중앙에서 관리
- 환경별 구성: 개발, 테스트, 운영 등 환경별로 구성을 분리하여 관리
- 실시간 구성 변경: 설정 변경 시 애플리케이션을 재시작하지 않고도 실시간으로 반영 가능
2. Spring Cloud Bus
Spring Cloud Bus를 사용하면 설정 변경사항을 실시간으로 클라이언트 APP에 반영 가능
3. 수동 구성 갱신
Spring Cloud Bus를 사용하지 않을 때, Config 서버 설정 파일을 변경하여 /actuator/refresh 엔드포인트 사용하고, 각 클라이언트에서 POST 방식으로 /actuator/refresh 로 호출하여 변경된 설정을 반영 가능
4. 실행 순서
eureka server -> config -> product
5. 구현
config 생성
build.gradle (config-server 추가)
implementation 'org.springframework.cloud:spring-cloud-config-server'
ConfigApplication.java 에 configserver 어노테이션 추가
@EnableConfigServer
@SpringBootApplication
public class ConfigApplication {
application.yml
server:
port: 18080
spring:
profiles:
active: native
application:
name: config-server
cloud:
config:
server:
native:
search-locations: classpath:/config-repo
eureka:
client:
service-url:
defaultZone: http://localhost:19090/eureka/
resources/config-repo/product-service.yml
server:
port: 19093
message: "product-service message"
resoures/config-repo/product-service-local.yml (두가지를 생성하는 이유는 local로 실행 했을 때 포트 비교하기 위함)
server:
port: 19083
message: "product-service-local message"
이후 Client(Product)에서 application.yml 수정하여 config 서버의 config-server을 가져오고, active:local을 통해 Product-service-local.yml으로 실행!
spring:
application:
name : product-service
profiles:
active: local
config:
import: "configserver:"
cloud:
config:
discovery:
enabled: true
service-id: config-server
다음으로 실시간으로 수동 구성 갱신을 반영하기 위해
product/application.yml 에 추가
management:
endpoints:
web:
exposure:
include: refresh
product/ProductController.java ( @RefreshScope를 추가하여 갱신될 수 있도록 한다.)
@RefreshScope
@RestController
public class ProductController

이를 통해 yml 파일의 메시지가 업데이트 됬다는 것을 확인할 수 있다.
'MSA' 카테고리의 다른 글
| MSA(Microservices Architecture) 총 정리 (0) | 2026.06.29 |
|---|---|
| 분산 추적(Zipkin) & 이벤트 드리븐 (0) | 2026.06.29 |
| 보안 구성 (0) | 2026.06.28 |
| API 게이트웨이 (Spring Cloud Gateway) (0) | 2026.06.27 |
| 서킷 브레이커 (Resilience4j) (0) | 2026.06.27 |