Spring Cloud Config
来源:互联网 发布:python retry 编辑:程序博客网 时间:2024/05/01 12:39
发博词
需要用过的人看。不是入门文档。
Environment 和 PropertySource
简单点说PropertySource和Environment 的区别是,假设配置文件中有Placeholder,那么你从PropertySource中获取的值是带Placeholder的,从Environment中获取的值是替换了Placeholder之后的值;
一般的实现是Environment会持有一个PropertySource的列表;
参考:
【Spring4揭秘 基础2】PropertySource和Enviroment
Spring3.1新属性管理API:PropertySource、Environment、Profile
架构
Spring Cloud Config的架构非常简单,一个Server,一个client。Server提供了多个基于HTTP协议的接口工Client调用获取信息。
理解几个概念
- spring cloud config label不是只指的branch,指定commitid、branch和tag的值都行,所以这些里面不要有重名的;
- 如果配置config-server也从远程拉取信息的话,需要将configserver应用的配置都放到bootstrap.yml
- 下载下来的库在/tmp/config-repo-,系统的临时文件夹/config-repo-随机id,basedir可以手动指定,最好手动指定一个,临时文件夹,有些操作系统会临时清理
- 因为网络的原因,所有想链接到config server的客户端都需要一个bootstrap.yml文件,spring.cloud.config.uri这个文件必须要有这个配置,而我们一般是用Discovery模式,只需要指定serviceid即可
- 我们已经知道application-*.yml文件的优先级了,那么本地远程都有配置文件的情况下,各自的优先级是远程优先级最高,其次是本地application系列文件,bootstrap优先级最低
- {application} 值是客户端的 “spring.application.name” 属性的值
- {profile} 的值是 客户端的”spring.profiles.active”的值,逗号分隔
- {label} 的值在configServer端设置,which is a server side feature labelling a “versioned” set of config files.
- git label (commit id, branch name or tag) “/”=》(_)
- Git URI可用变量:{application} and {profile} (and {label},客户端可控的变量是{application} and {profile},label是服务器端控制的,如何使用{application} and {profile}也是服务器端控制的
ConfigServer endpoint
name-profiles.properites,yml,json
label/name-profile.
name/profile/label
name/profiles
label/name-profile.pyj
name/profile/label
name/profile/label
这两个接口是一个,上面这个是下面的label=null的版本,也就是label的默认值版本
/{name}-{profiles}.yml /{name}-{profiles}.yaml
/{label}/{name}-{profiles}.yml /{label}/{name}-{profiles}.yaml
label applicationname profile path resolvePlaceholders
仓库,仓库下的目录(searchPaths)
字符串匹配
label 在前面
name-profile在前面
json,yml,ymal,proprieies结尾
- 其实是可以控制这五个部分
public Environment(Environment env) { this(env.getName(), env.getProfiles(), env.getLabel(), env.getVersion(), env.getState());}
要使用ConfigServer注意点
1. spring.application.name git仓库的名字要有规律,能对应起来
2. git仓库名字和配置文件所在目录也要能对应起来
使用模式
通过在url和searchpaths上使用application、profile和label,产生了下面三种常用的方式:
1. all Instances in one repo
2. one repo per application
3. one repo per profile
整合Spring Cloud Bus
- 使用属性的地方记得加@RefreshCope注解
- configserver每次都刷新,不管想刷新谁
- spring cloud:spring cloud config
- 开始Spring Cloud Config
- Spring Cloud Config
- 关于spring cloud config
- spring cloud config使用
- Spring Cloud Config
- 开始Spring Cloud Config
- Spring Cloud Config 实践
- Spring Cloud Config
- Spring Cloud Config
- spring cloud config 配置
- 聊聊 Spring Cloud Config
- Spring Cloud Config Server
- 详解Spring Cloud Config
- Spring Cloud Config
- spring cloud config
- Spring Cloud Config
- Spring Cloud Config (1)
- Java
- 统一开户前置模拟开户流程
- HDU 6168 Numbers 优先队列
- Arccatalog连接到postgresql失败问题
- Orleans---持久化
- Spring Cloud Config
- gets()getchar()与缓冲区的问题
- 常见的安全算法
- 吃青春饭”的程序员们:再过 5 年,你还在写代码吗?
- 【Leetcode】【python】Valid Parentheses
- error C2275 : 'UNICODE_STRING' :illegal use of this type as an expression
- Nginx的启动和停止
- IOS 设置一个UIView里面的全部控件状态
- 欢迎使用CSDN-markdown编辑器