SpringCloudConfig
方便服务配置文件统一管理,实时更新
组成
在spring cloud config组件中,分两个角色,一是config server,二是config client
Config Server是一个可横向扩展、集中式的配置服务器,它用于集中管理应用程序各个
环境下的配置,默认使用Git存储配置文件内容,也可以使用SVN存储,或者是本地文件
存储。
Config Client是Config Server的客户端,用于操作存储在Config Server中的配置内容。
微服务在启动时会请求Config Server获取配置文件的内容,请求到后再启动容器
配置中心微服务
依赖
<dependency>
groupId>org.springframework.cloud</groupId>
artifactId>spring-cloud-config-server</artifactId>
</dependency>
启动类
@SpringBootApplication
@EnableConfigServer
public class ConfigApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigApplication.class, args);
}
}
application.yml
server:
port: 9998
spring:
application:
name: tensquare‐config
cloud:
config:
server:
git:
uri: https://gitee.com/ld/tensquare‐config.git
basedir: E:\Java\config\basedir #可以使用这个配置项来指定本地git仓库的路径
#git的用户名
spring.cloud.config.server.git.username=username
#git的密码
spring.cloud.config.server.git.password=password
配置客户端
依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
bootstrap.yml
spring:
cloud:
config:
#/{label}/{name}-{profiles}.yml
name: user #一般以服务名来命名
profile: dev #一般作为环境标识,开发环境(dev)、测试环境(test)、生产环境(product)
label: master
uri: http://127.0.0.1:9998
假如在不同环境下有很多共用的配置,我们可以再创建一个user.yml用来存放共同配置
springcloud-config取配置时,会将你的对应环境配置与user.yml合并后再返回(前缀name相同)。
SpringCloudConfig的更多相关文章
- SpringCloud-config分布式配置中心
为什么要统一管理微服务配置? 随着微服务不断的增多,每个微服务都有自己对应的配置文件.在研发过程中有测试环境.UAT环境.生产环境,因此每个微服务又对应至少三个不同环境的配置文件.这么多的配置文件,如 ...
- SpringCloudConfig配置中心git库以及refresh刷新
基于git库的Spring Cloud Config配置中心代码demo下载地址:https://gitlab.com/mySpringCloud/config-git SpringBoot版本: 1 ...
- SpringCloud系列十:SpringCloudConfig 高级配置(密钥加密处理(JCE)、KeyStore 加密处理、SpringCloudConfig 高可用机制、SpringCloudBus 服务总线)
1.概念:SpringCloudConfig 高级配置 2.具体内容 在 SpringCloudConfig 之中考虑到所有配置文件都暴露在远程仓库之中的安全性问题,所以提供有安全访问的处理机制,这样 ...
- SpringCloud系列九:SpringCloudConfig 基础配置(SpringCloudConfig 的基本概念、配置 SpringCloudConfig 服务端、抓取配置文件信息、客户端使用 SpringCloudConfig 进行配置、单仓库目录匹配、应用仓库自动选择、仓库匹配模式)
1.概念:SpringCloudConfig 基础配置 2.具体内容 通过名词就可以发现,SpringCloudConfig 核心作用一定就在于进行配置文件的管理上.也就是说为了更好的进行所有微服务的 ...
- spring-cloud-config——Quick Start
参考资料: https://cloud.spring.io/spring-cloud-static/spring-cloud-config/1.4.0.RELEASE/single/spring-cl ...
- 六:SpringCloud-Config
十:SpringCloudConfig分布式配置中心 1. 概述 1.1 分布式系统面临的 配置问题 微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的 ...
- spring-cloud-config笔记
忽略元数据末尾 回到原数据开始处 spring-cloud-config 简单来讲就是spring-cloud实现的分布式配置中心.与之前介绍的开源配置服务方案 disconf是一样的,spring- ...
- spring-cloud-config 配置中心快速上手
spring-cloud-config 配置中心实现 Spring Cloud Config 用于为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持,分为server端和client端. s ...
- springcloud学习之路: (五) springcloud集成SpringCloudConfig分布式配置中心
SpringCloud全家桶中的分布式配置中心SpringCloudConfig, 它使用git来管理配置文件, 在修改配置文件后只需要调用一个接口就可以让新配置生效, 非常方便. SpringClo ...
- SpringCloud-Config通过Java访问URL对敏感词加密解密
特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过.如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处:http://www.cnblogs.com/ ...
随机推荐
- <爬虫>相关的知识
1.概念.工具和HTTP 什么是爬虫 模拟客户端发送网络请求,获取响应,按照规则提取数据 爬虫的数据去哪了 展示到网页上(百度新闻,今日头条) 进行分析,从数据中寻找规律(指数网站:百度指数) 需要的 ...
- Go学习笔记:Linux下安装Go语言
CentOS7.6安装Go-1.12.9版本 1. 下载安装包到当前目录下> wget https://dl.google.com/go/go1.12.9.linux-amd64.tar.gz2 ...
- 利用ffmpeg进行视频软解播放
前段时间,公司的一个项目需要一个rtsp的播放库,原本打算直接用vlc播放的,但我觉得vlc太庞大了,很多功能没必要,还不如用ffmpeg+d3d简单的实现一个库,因此就有了今天讲的这个东西.一个解码 ...
- FastStone Capture 文件名设置小记录
我使用的FastStone Capture 的文件名设置 文件名称模板 fs$Y$M$D#####@ 起始于: [1] 重置 [ 选中] 新的一天自动重置为1
- bzoj1003题解
[题意分析] 给你一张无向图,固定起点和终点,除这两点外每个点都有可能消失一段时间(保证起点和终点相互可达),每天选择的路径总长,以及对路径的修改都有代价,求给定时间内最小代价保证起点终点始终连通. ...
- Optimal Marks SPOJ - OPTM
传送门 一个无向图,每个点有点权,某些点点权确定了,某些点由你来确定,边权为两个点的异或和,要使边权和最小. 这不是一道按位做最小割的大水题么 非常开心地打了,还非常开心地以为有spj,然后非常开心地 ...
- CentOS 启动提示unexpected inconsistency;RUN fsck MANUALLY, ntfs的input/output Error,InPageError c000009c使用chkdsk修复磁盘,12款Linux系统恢复工具
CentOS这两天服务器出了问题了,提示如下: unexpected inconsistency;RUN fsck MANUALLY An error occurred during the file ...
- Java-Class-@I:org.springframework.web.bind.annotation.RequestBody
ylbtech-Java-Class-@I:org.springframework.web.bind.annotation.RequestBody 1.返回顶部 2.返回顶部 1. package ...
- row_number() over(partition by a order by b desc) rn 用法
转载于:http://www.blogjava.net/kxbin/articles/360195.html 可以看看http://jingyan.baidu.com/article/9989c746 ...
- ncurse 笔记
初始化与结束 为了使用 NCURSES 库,你应该 #include <curses.h>,在编译时,应该加上 -lncurses. stdscr 一般地,第一个函数调用必须是 inits ...