Config Server 를 활용하여 공통으로 환경 변수를 관리할 수 있게 되었지만 만약, 환경 변수가 변경된 경우 여전히 서버를 재기작 시켜야 한다.
Spring Actuator 의 refresh 를 사용하면 환경 변수를 변경했을때 서버의 재시작 없이 적용할 수 있다.
Actuator 를 모든 애플리케이션에 추가
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'
application.yml
추가
management:
endpoints:
web:
exposure:
include: health, beans, refresh
exposure.include
는 Actuator 가 외부에 노출할 address 를 지정refresh
가 환경 변수 변경을 위한 주소http://localhost:{port}/actuator/refresh
에 POST 요청
요청을 하게 되면 actuator 가 환경 변수를 다시 로딩하게 된다.