Spring Cloud Config Server 如何将纯文本文件推送到配置客户端应用程序? [英] How Spring Cloud Config Server PUSH plain text files to Config Client Application?

查看:73
本文介绍了Spring Cloud Config Server 如何将纯文本文件推送到配置客户端应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止我已经实现了:

What I have implemented so far are:

  1. 带有本机"存储库的 Spring Cloud 配置服务器.

spring.profiles.active:原生

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

配置客户端应用程序在服务 bean 上标注了 @RefreshScope.

Config Client App has @RefreshScope annotated on Service bean.

所以/config-repo 有 3 个文件 - application.yaml、client.yaml 和 client.json配置客户端应用程序肯定会自动重新加载所有 yaml 属性更改.但是,client.json 没有.

So /config-repo has 3 files - application.yaml, client.yaml and client.json All yaml properties changes will be auto reloaded by Config Client App for sure. However, client.json didn't.

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

Based on https://github.com/spring-cloud/spring-cloud-config/issues/147, I can fetch the file on Config Client App through REST api call to Config Server, with /{appname}/{profile}/{label}/client.json

问题是:

1) Config Server 是否通过本机"监视此纯文本文件更改?

1) Is Config Server monitoring this plain text file changes by "native"?

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

2) how can Config Client App auto reload this client.json once it's updated? (I can have schedule task to call Config server, but this isn't ideal.)

推荐答案

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

the Config client: restTemplate.getForObject("http://localhost:8080/application/default/master/testing-dev.json",String.class);

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

can get the .json suffix file content ,but i think it don't get the file content ,have other way to get the file content

这篇关于Spring Cloud Config Server 如何将纯文本文件推送到配置客户端应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆