7. 提供纯文本

您的 applications 可能需要根据其环境定制的通用 plain-text configuration files,而不是使用Environment抽象(或 YAML 或 properties 格式中的其中一个替代表示)。 Config Server 通过/{name}/{profile}/{label}/{path}处的附加端点提供这些端点,其中nameprofilelabel与常规环境端点具有相同的含义,但path是文件 name(例如log.xml)。此端点的源 files 的位置与环境 endpoints 的方式相同。相同的搜索路径用于 properties 和 YAML files。但是,不是聚合所有匹配的资源,而是返回第一个到 match 的资源。

找到资源后,通过使用提供的 application name,profile 和 label 的有效Environment来解析正常格式(${…})的占位符。通过这种方式,资源端点与环境 endpoints 紧密集成。考虑 GIT 或 SVN repository 的以下 example:

application.yml
nginx.conf

其中nginx.conf看起来像这样:

server {
    listen              80;
    server_name         ${nginx.server.name};
}

application.yml这样:

nginx:
  server:
    name: example.com
---
spring:
  profiles: development
nginx:
  server:
    name: develop.com

/foo/default/master/nginx.conf资源可能如下:

server {
    listen              80;
    server_name         example.com;
}

/foo/development/master/nginx.conf这样:

server {
    listen              80;
    server_name         develop.com;
}

与环境 configuration 的源 files 一样,profile用于解析文件 name。因此,如果您想要一个 profile-specific 文件,/*/development/*/logback.xml可以通过一个名为logback-development.xml的文件解析(优先于logback.xml)。

如果您不想提供label并让服务器使用默认标签,则可以提供useDefaultLabel请求参数。因此,default profile 的前面的 example 可能是/foo/default/nginx.conf?useDefaultLabel