codecamp

SpringCloud 提供纯文本

除了使用​Environment​抽象(或YAML或属性格式的抽象表示之一)之外,您的应用程序可能需要根据其环境量身定制的通用纯文本配置文件。Config Server通过位于​/{application}/{profile}/{label}/{path}​的附加终结点提供了这些终结点,其中​application​,​profile​和​label​与常规环境终结点具有相同的含义,但是path是指向以下环境的路径文件名(例如​log.xml​)。该端点的源文件与环境端点的定位方式相同。属性和YAML文件使用相同的搜索路径。但是,不是汇总所有匹配资源,而是仅返回第一个要匹配的资源。

找到资源后,可通过对提供的应用程序名称,配置文件和标签使用有效的​Environment​来解析常规格式(​${…​}​)的占位符。通过这种方式,资源端点与环境端点紧密集成在一起。考虑以下用于GIT或SVN存储库的示例:

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;
}

用于环境配置的源文件一样,profile用于解析文件名。因此,如果要使用特定于配置文件的文件,可以通过名为logback-development.xml(优先于logback.xml)的文件来解析/*/development/*/logback.xml

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


SpringCloud 提供其他格式
SpringCloud 嵌入配置服务器
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

三、Spring Cloud Netflix

SpringCloud Hystrix超时和Ribbon客户

SpringCloud 重试失败的请求

五、Spring Cloud Stream

六、SpringCloud Binder实现

SpringCloud 重试RabbitMQ Binder

SpringCloud Dead-Letter队列处理

八、Spring Cloud Sleuth

SpringCloud 当前Span

十二、Spring Cloud for Cloud Foundry

十三、Spring Cloud Contract

Spring Cloud Contract验证程序设置

SrpingCloud Gradle项目

十五、Spring Cloud网关

Spring Cloud 配置路由谓词工厂和网关过滤工厂

Spring Cloud TLS / SSL

Spring Cloud网关配置

SpringCloud 故障排除

十八、Spring Cloud GCP

Spring Cloud GCP Spring资源

Spring Cloud Spring JDBC

Spring Cloud Redis的Cloud Memorystore

Spring Cloud 云身份识别代理(IAP)身份验证

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }