Spring 具有非 Spring 应用程序的云配置服务器

Spring Cloud Config Server With Non-Spring Application

所以我有一个 Servlet/JSP 网络应用程序。我们使用 Ant 脚本构建脚本来为不同的环境构建属性,在部署期间使用大量过滤。但我们现在正在移动应用程序以使用 Maven 构建。我们正在考虑使用 Spring Cloud Config 作为我们拥有的所有环境的 属性 文件的集中存储库。所以我的问题主要是:

  1. Can we use Spring Cloud Config Server to host properties and fetch it in a non-Spring application?

  2. Can we use Spring Cloud Config to fetch XML, XSD, Text files too? (This is a bit of stretch but just asking if its possible)

我们不打算使用 GIT 作为 属性 的存储库,只是使用文件系统。

如有指点,将不胜感激。

Spring Cloud Config Server 提供了一个在 "Quick Start" section of the Spring Cloud Config documentation 中描述的 HTTP API。您可以使用 GET 请求来获取特定应用程序和配置文件的配置属性,例如:

curl http://config-server-host:8888/my-application/dev

使用 HTTP API 允许您将 Config Server 与不基于 Spring 的应用程序集成。

Spring 云配置服务器还可以 return 非 属性 文件作为“纯文本”处理。请查看 section "Serving Plain Text" in the Spring Cloud Config documentation:

The Config Server provides these through an additional endpoint at /{application}/{profile}/{label}/{path}, where application, profile, and label have the same meaning as the regular environment endpoint, but path is a path to a file name (such as log.xml).

因此,

curllogback.xml 文件的请求如下所示:

curl http://config-server-host:8888/my-application/dev/logback.xml?useDefaultLabel