Spring Cloud Config Server 配置总结
2017-12-21 16:40
507 查看
Spring Cloud Config Server 配置总结
Spring Cloud 微服务使用配置仓库进行配置管理的时候,需要注意一些东西,自己走了一些弯路,不断去修改配置调试程序总结了一点经验,在这里记录一下。只要依赖Config Server的应用必须在bootstrap.yml里配置相关配置仓库的信息
本人习惯使用yml配置文件,当然也可使用properties
config server 的配置(application.yml或bootstrap.yml)server: port: 7003 spring: application: name: config-center cloud: config: server: git: uri: {https://xxxxx/config.git} search-paths: config-repo username: {username} password: {password} eureka: client: serviceUrl: defaultZone: http://localhost:7000/eureka/ #对称加密秘钥 #该配置也可放到环境变量 ENCRYPT_KEY #使用到数据源的密码spring.datasource.password={cipher}[加密内容] #使用前提,需要JCE包,去oracle下载,将下载来的文件解压, #将local_policy.jar和US_export_policy.jar文件复制到jre/lib/security目录下 encrypt: key: {encryptKey} #连接到配置中心的客户端进行安全验证 security: user: name: {name} password: {password}
app-name 的配置(依赖配置中心的配置文件名必须是bootstrap.yml)
spring: cloud: config: discovery: enabled: true service-id: config-center profile: default #Config Server 宕机后快速反应和重试 fail-fast: true retry: # 初始重试间隔时间(单位毫秒)默认1000 multiplier: 1000 # 最大重试次数 默认6次 max-attempts: 6 #安全验证 username: {username} password: {password} application: name: app-name #注册中心 eureka: client: serviceUrl: defaultZone: http://localhost:7000/eureka/[/code]
bootstrap.yml 与 application.yml
引用自stackoverflowbootstrap.ymlis loaded beforeapplication.yml.
It is typically used for the following:
when using Spring Cloud Config Server, you should specifyspring.application.nameandspring.cloud.config.server.git.uriinsidebootstrap.yml
someencryption/decryption information
Technically,bootstrap.ymlis loaded by a parent SpringApplicationContext. That parentApplicationContextis loaded before the one that usesapplication.yml.
个人补充,如果配置是服务模式,也就是配置中心 (Config Server) 也注册到Eureka,那么eureka.client.serviceUrl. defaultZone也应该配置到客户端的bootstrap.yml里,这样客户端才能发现(Discover) 配置中心
相关文章推荐
- spring cloud config server 配置中心
- 为Spring Cloud Config Server配置远程git仓库
- 为Spring Cloud Config Server配置远程git仓库
- SpringCloudConfig使用总结【分布式配置】
- Spring Cloud Config Server 配置说明
- Spring Cloud之config server(配置中心)
- SpringCloud Config Server使用SVN Hooks实现动态刷新配置
- spring cloud config server使用svn来作为外部配置中心
- 4. 分布式配置中心 springcloud-config-server
- spring cloud config-server 高可用配置中心
- J360-cloud SpringCloud系列一:分布式配置服务器ConfigServer
- spring cloud config server 使用本地配置文件报错
- SpringCloud | 高可用配置中心 config(九)
- 史上最简单的SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)
- Spring Cloud Config Server 实践
- SpringCloud Config Server中{application}等占位符使用场景设置默认拉去分支
- Spring Cloud Config服务端配置细节(二)之加密解密
- spring cloud config 用svn做配置文件仓库
- spring cloud :五、分布式配置中心(spring cloud config)
- spring cloud config 配置自建git服务器报错解决