반응형
RefreshScope 적용안되는 경우
Spring Cloud 튜토리얼에서 @RefreshScope 를 사용하여 서버를 재시작 할 필요없이 설정값을 변경하기 위해 Postman을 이용해 Refresh 를 해주는 작업이 필요한데 기존과 다른 부분이 있습니다.
기존방법
- @RefreshScope 추가
- config-server 의 config-client.properties 에서 값 변경
- config-server 의 config-client.properties git commit
- postman 으로 Send
Post : localhost:8982/refresh
- 확인
Localhost:8982/rest/message
변경방법
- @RefreshScope 추가
- config-client 의 bootstrap.properties 에 값 추가
management.endpoints.web.exposure.include=*
- config-server 의 config-client.properties 에서 값 변경
- config-server 의 config-client.properties git commit
- postman 으로 Send
Post : localhost:8982/actuator/refresh
주의
1. git commit 필요
Config-server 의 config-client.properties 값 변경 후 commit 을 하지 않으면 값 적용이 안되며 그 이전에 postman 으로 Send 할 때 리턴값이 [] << 이렇게 나옵니다.
제대로 된 리턴값은 아래와 같습니다.
[
"config.client.version",
"message"
]
2.actuator 영향
Config-client 의 bootstrap.properties 에 endpoints 와 관련한 값 추가를 해야하며 Postman 으로 Refresh 수행하는 url 도 /actuator/ 가 추가되었습니다.
참고
- Spring Cloud 튜토리얼 : https://www.youtube.com/watch?v=b2ih5RCuxTM
- Actuator & endpoint 관련 : http://wonwoo.ml/index.php/post/1947
반응형
'JAVA > Spring' 카테고리의 다른 글
의존 관계 자동 설정에 관하여 (간단) (0) | 2016.07.03 |
---|---|
Spring FrameWork에 대하여 (0) | 2016.07.03 |