7. 提供纯文本
而不是使用Environment
抽象(或 YAML 或 properties 格式中的其中一个替代表示),您的 applications 可能需要通用的纯文本 configuration files,根据其环境量身定制。 Config Server 通过/{name}/{profile}/{label}/{path}
处的附加端点提供这些端点,其中“name”,“ profile”和“label”与常规环境端点具有相同的含义,但“path”是文件 name(e.g. log.xml
)。此端点的源 files 的位置与环境 endpoints 的方式相同:使用与 properties 或 YAML files 相同的搜索路径,但不是聚合所有匹配的资源,而是返回第一个到 match 的资源。
找到资源后,使用提供的 application name,profile 和 label 的有效Environment
解析正常格式(${…}
)的占位符。通过这种方式,资源端点与环境 endpoints 紧密集成。 例如,如果您有 GIT(或 SVN)repository 的这种布局:
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
。