配置管理工具包,让你可以把配置放到远程服务器,集中化管理集群配置,目前支持本地存储、Git以及Subversion。

1.服务端

创建spring boot 项目

主要依赖

   <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>

新版本好像不包括 web 需加入web依赖

 <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

在启动类上声明

@EnableConfigServer

配置文件 application.yml
spring:
application:
name: config
cloud:
config:
server:
git:
uri: #git 地址
search-paths: #git的路径
username: #账号
password: #密码
basedir: #本地存放路径
label: master #分支 eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
server:
port: 8888
2.客户端
引入依赖
        <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

配置文件 要用bootstrap.yml  (用来程序引导时执行,应用于更加早期配置信息读取)

用于有eureka的配置 通过id寻找配置中心
#spring:
# cloud:
# config:
# discovery:
# service-id: config
# enabled: true
# profile: dev
# name: product
# label: master 通过url 寻找配置中心
spring:
cloud:
config:
label: master #分支
profile: dev #配置描述
uri: http://localhost:8888
name: product #名称 设置了application.name 可省略
 
配置访问规则 
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties

{application}应用名称

{profile} 配置文件的版本 如application-dev.yml、application-test.yml、application-prod.yml。

{label} 表示 git 分支,默认是 master 分支

applicattion-dev.yml  applicattion-prod.yml  有共同配置  则可放在 applicattion.yml 中  ,访问时得到的文件 合并了application.yml中的内容

												

配置中心 Spring Cloud config的更多相关文章

  1. 第六篇: 分布式配置中心(Spring Cloud Config)

    一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件. 在Spring Cloud中,有分布式配置中心组件spring cloud confi ...

  2. 一起来学Spring Cloud | 第七章:分布式配置中心(Spring Cloud Config)

    上一章节,我们讲解了服务网关zuul,本章节我们从git和本地两种存储配置信息的方式来讲解springcloud的分布式配置中心-Spring Cloud Config. 一.Spring Cloud ...

  3. Spring Cloud Config(一):聊聊分布式配置中心 Spring Cloud Config

    目录 Spring Cloud Config(一):聊聊分布式配置中心 Spring Cloud Config Spring Cloud Config(二):基于Git搭建配置中心 Spring Cl ...

  4. SpringCloud(6)分布式配置中心Spring Cloud Config

    1.Spring Cloud Config 简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组 ...

  5. springboot+cloud 学习(五)统一配置中心 spring cloud config + cloud bus + WebHooks +RibbitMQ

    前言 微服务要实现集中管理微服务配置.不同环境不同配置.运行期间也可动态调整.配置修改后可以自动更新的需求,Spring Cloud Config同时满足了以上要求.Spring Cloud Conf ...

  6. SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)

    一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组件spring cloud config ...

  7. 史上最简单的SpringCloud教程 | 第七篇: 高可用的分布式配置中心(Spring Cloud Config)

    上一篇文章讲述了一个服务如何从配置中心读取文件,配置中心如何从远程git读取配置文件,当服务实例很多时,都从配置中心读取文件,这时可以考虑将配置中心做成一个微服务,将其集群化,从而达到高可用,架构图如 ...

  8. 史上最简单的SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)

    一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件. 在Spring Cloud中,有分布式配置中心组件spring cloud confi ...

  9. spring boot 2.0.3+spring cloud (Finchley)6、配置中心Spring Cloud Config

    https://www.cnblogs.com/cralor/p/9239976.html Spring Cloud Config 是用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持, ...

随机推荐

  1. 消金ABS

    对于持牌消金公司来说,发行ABS需满足至少3年经营期限的硬性规定,目前已开业的24家消金公司里,有15家符合此项规定. 2019年下半年以来,个人消费金融领域共发行了15个资产证券化产品,发行规模达4 ...

  2. PHP内置常量,和可变变量,常量的定义

    关键常量 可变变量----变量名是变量的变量 常量的定义

  3. Java-Base64Fiend工具类

    import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; impo ...

  4. 基于LVM 测试磁盘写性能.md

    准备工作 /dev/sdb 创建一个卷组,基于卷组创建5个逻辑卷,各100G 在10.10.88.214 新建5台虚拟机,每台虚拟机用到lvm建的逻辑卷 dd 压测 在每台虚拟机上执行dd 命令: d ...

  5. js自定义事件CustomEvent、Event、TargetEvent

    1.Event Event 对象代表事件的状态,比如事件在其中发生的元素.键盘按键的状态.鼠标的位置.鼠标按钮的状态. 事件通常与函数结合使用,函数不会在事件发生前被执行! Event的事件都是系统自 ...

  6. java mybaits 调用存储过程

    @Override public BaseResultMessage saveOrderConfirm(String billNo) { BaseResultMessage rm = Utils.re ...

  7. jQuery属性操作之值操作

    值操作是对DOM属性value进行读取和设置操作. 比如html(). text(). val(). 1. html 1. 1 html()获取值 返回值:String 描述:获取集合中第一个匹配元素 ...

  8. SQL复杂查询语句-SELECT * FROM cs WHERE score>70 GROUP BY s_id HAVING COUNT(*)>1

    如果同时存在where,group by,的时候的执行顺序应该是这样的: 1,首先where后面添加条件把数据进行了过滤,返回一个结果集 2,然后group by将上面返回的结果集进行分组,返回一个结 ...

  9. navicat for mysql安装

    搜索一款navicat for mysql然后进行下载. 步骤阅读 2 当我们下载完成之后首先进行数据包的解压,同时可以运行navicat for mysql程序. 破解工具下载:https://pa ...

  10. smarty逻辑运算符

    smarty逻辑运算符 eq        equal : 相等 neq       not equal:不等于 gt        greater than:大于 lt        less th ...