환경설정 자동 반영을 배워서 남주자 - gae-jang-mo/app GitHub Wiki

Cloud Config를 사용하는 클라이언트 쪽의 application.yml에 refresh라는 엔드포인트를 노출시킵니다.

management:
  endpoints:
    web:
      exposure:
        include: "refresh"

설정정보가 들어가는 클래스에 @RefreshScope 애노테이션을 달아줍니다.

@RefreshScope
@Component
public class ApiInvoker {
    private RestTemplate restTemplate;
...

설정정보를 변경하여 private repository로 push 합니다. Config-Server 쪽에서는 내용이 자동 반영이 됩니다.

하지만, Client 쪽에서는 POST 요청을 하나 더 보내야 합니다.

POST [서버주소]/actuator/refresh

그러면 변경된 필드들이 나오고 실제 반영이 되게 됩니다.