Spring Cloud Cofig 1,2git
http://www.javashuo.com/article/p-wvxkasuv-kv.htmlweb
http://www.javashuo.com/article/p-zwncwhcr-kx.htmlspring
1.客户端gradle引入包app
compile 'org.springframework.boot:spring-boot-starter-actuator' compile 'org.springframework.cloud:spring-cloud-starter-bus-amqp'
2.客户端 application.properties spring-boot
management.endpoints.web.exposure.include=* #actuator容许访问的连接
#rabbitmq配置=================单机刷新能够不用配置
spring.rabbitmq.host=xxx.xxxx.xxx.xx
spring.rabbitmq.port=5672
spring.rabbitmq.prod.port=5674
spring.rabbitmq.username=xxx
spring.rabbitmq.password=xxxx
spring.rabbitmq.virtual-host=/
spring.rabbitmq.publisher-confirms=true测试
3.添加Controllergradle
再类注解@RefreshScopespa
添加方法打印配置文件中的tmp.file.path.net
咱们当前git库的文件值是C:/home/test1/blog
启动客户端,能够启动多个咱们此次用2个客户端作为测试,端口分别是12000,12001
发布请求 http://localhost:12000/public/tmpPath , http://localhost:12001/public/tmpPath
能够发现返回的都是 C:/home/test1/
4.修改数据
修改数据C:/home/test/而且提交git库
请求 http://localhost:12000/actuator/refresh 进行单机刷新,接口返回发生变更的参数
访问 http://localhost:12000/public/tmpPath 发现 C:/home/test1/ 已经变成 C:/home/test/
访问 http://localhost:12001/public/tmpPath 发现依旧仍是 C:/home/test1/
若是是集群的状况些修改了参数要一个个去刷新有可能漏刷也增长了工做量。
这时咱们使用 Spring Cloud bus 帮助咱们同一刷新就很方便了。请求 http://localhost:12000/actuator/bus-refresh
这时候咱们看 http://localhost:12001/public/tmpPath ,发现 C:/home/test1/ 也已经变成 C:/home/test/
这样就能经过刷新一台客户端从而刷新所有 客户端了。