springcloud(第二篇)springcloud config 修改配置
在git端修改配置后如何让客户端生效?
访问接口修改
- refresh
post方式执行http://localhost/refresh 会刷新env中的配置 - restart
如果配置信息已经注入到bean中,由于bean是单例的,不会去加载修改后的配置
需要通过post方式去执行http://localhost/restart,
需要通过application.properties
中配置endpoints.restart.enabled=true启动指定的端口
弊端: 通过restart耗时比较长,因此就有了RefreshScope
RefreshScope
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
在执行refresh时会刷新bean中变量值。
ok ~ it’s work ! more about is here
转载请注明
http://blog.csdn.net/liaokailin/article/details/51307603