Spring Cloud Config Server如何将纯文本文件推送到Config Client Application?

时间:2016-11-15 11:08:49

标签: spring spring-cloud spring-cloud-stream spring-cloud-config spring-cloud-bus

到目前为止我实施的是:

  1. 具有“本机”仓库的Spring Cloud Config服务器。
  2. spring.profiles.active: native

    spring.cloud.config.server.native.searchLocations: file:/path/to/config-repo

    1. Config Server正在通过RabbitMQ向Config Client App发送通知,如http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_push_notifications_and_spring_cloud_bus

    2. Config Client App在Service bean上注释了@RefreshScope。

    3. 所以/ config-repo有3个文件 - application.yaml,client.yaml和client.json 所有yaml属性更改将由Config Client App自动重新加载。但是,client.json没有。

      基于https://github.com/spring-cloud/spring-cloud-config/issues/147,我可以通过REST api调用Config Server来获取Config Client App上的文件,使用/ {appname} / {profile} / {label} /client.json

      问题是:

      1)Config Server监控此纯文本文件是否更改为“native”?

      2)Config Client App如何在更新后自动重新加载此client.json? (我可以通过调度任务来调用Config服务器,但这并不理想。)

1 个答案:

答案 0 :(得分:1)

Config客户端: restTemplate.getForObject( “http://localhost:8080/application/default/master/testing-dev.json”,String.class);

可以获取.json后缀文件内容,但我认为它没有获取文件内容,有其他方式来获取文件内容

相关问题