配置中心 Spring Cloud config
配置管理工具包,让你可以把配置放到远程服务器,集中化管理集群配置,目前支持本地存储、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的更多相关文章
- 第六篇: 分布式配置中心(Spring Cloud Config)
一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件. 在Spring Cloud中,有分布式配置中心组件spring cloud confi ...
- 一起来学Spring Cloud | 第七章:分布式配置中心(Spring Cloud Config)
上一章节,我们讲解了服务网关zuul,本章节我们从git和本地两种存储配置信息的方式来讲解springcloud的分布式配置中心-Spring Cloud Config. 一.Spring Cloud ...
- Spring Cloud Config(一):聊聊分布式配置中心 Spring Cloud Config
目录 Spring Cloud Config(一):聊聊分布式配置中心 Spring Cloud Config Spring Cloud Config(二):基于Git搭建配置中心 Spring Cl ...
- SpringCloud(6)分布式配置中心Spring Cloud Config
1.Spring Cloud Config 简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组 ...
- springboot+cloud 学习(五)统一配置中心 spring cloud config + cloud bus + WebHooks +RibbitMQ
前言 微服务要实现集中管理微服务配置.不同环境不同配置.运行期间也可动态调整.配置修改后可以自动更新的需求,Spring Cloud Config同时满足了以上要求.Spring Cloud Conf ...
- SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)
一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组件spring cloud config ...
- 史上最简单的SpringCloud教程 | 第七篇: 高可用的分布式配置中心(Spring Cloud Config)
上一篇文章讲述了一个服务如何从配置中心读取文件,配置中心如何从远程git读取配置文件,当服务实例很多时,都从配置中心读取文件,这时可以考虑将配置中心做成一个微服务,将其集群化,从而达到高可用,架构图如 ...
- 史上最简单的SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)
一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件. 在Spring Cloud中,有分布式配置中心组件spring cloud confi ...
- spring boot 2.0.3+spring cloud (Finchley)6、配置中心Spring Cloud Config
https://www.cnblogs.com/cralor/p/9239976.html Spring Cloud Config 是用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持, ...
随机推荐
- ngnix之笔记
############################################################################# 我们在使用的时候会遇到很多的恶意IP攻击,这 ...
- MySQL 将数据文件分布到不同的磁盘
https://blog.csdn.net/john_chang11/article/details/51783632 [root@test1 temp]# vi /etc/my.cnf [mysql ...
- Java-IPDeal工具类
/** * IP处理类 */ import java.sql.*; public class IPDeal { /** * 通过ip地址查询地区名称 * @param strip * @return ...
- Oracle之:Function :getcurrdate()
getdate()函数连接请戳这里 create or replace function getcurrdate(i_date date) return date is v_date date; v_ ...
- js比较两个时间的大小
function checkdate(s,e){ //得到日期值并转化成日期格式,replace(/-/g, "//")是根据验证表达式把日期转化成长日期格式,这样再进行判断就好判 ...
- jmeter+jenkins+git+ant
摘自:https://www.cnblogs.com/syw20170419/p/10732167.html 使用场景: 多人协作,共同完成脚本的编写,脚本之间进行合并后,用远程构建运行脚本.做接口的 ...
- Latex的beamer幻灯片图形不编号的问题
在beamer幻灯片中如果插入图形,一般不会显示图形编号,这是其默认模式,但我们可以通过设置给图形编号.解决办法是: 在导言区加上命令: \setbeamertemplate{caption}[num ...
- PHP-过滤器-连接数据库-解析XML
PHP 过滤器 what? PHP 过滤器用于验证和过滤来自非安全来源的数据,比如用户的输入. 验证和过滤用户输入或自定义数据是任何 Web 应用程序的重要组成部分. 设计 PHP 的过滤器扩展的目的 ...
- liunx 一些文件下载上传的命令
xshell 上传 rz sftp 语法: put path/filename.txt Put -r path/文件夹 或者 put “path/filename.txt” Put -r “path/ ...
- 教程:myeclipse在线安装svn插件
SVN 版本控制,相信开发过程中都很多有用到,今天在myeclipse 在线安装了SVN插件.下面是具体步骤,记录下,希望对有需要的朋友提供帮助. 要求: Myeclispe,电脑能连接互联网 步骤: ...