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/ ...
随机推荐
- 牛客网多校训练第九场H Cutting Bamboos
题目链接:https://ac.nowcoder.com/acm/contest/889/H 题意:给出n颗竹子的高度,q次询问,每次询问给出l,r,x,y,每次选取[l,r]中的竹子,砍y次砍掉所有 ...
- 209. Minimum Size Subarray Sum【滑动窗口】
Given an array of n positive integers and a positive integer s, find the minimal length of a contigu ...
- 如何在react中实现一个倒计时组件
倒计时组件 import React, { Component } from 'react' import $ from 'jquery' import "../../css/spellTE ...
- Unity中实现网格轮廓效果,选中边框效果
问题背景: 最近要实现选中实体的高亮效果,要那种类似于unity中Outline的效果,网格轮廓高亮效果. 效果图: 具体代码: OutlineEffect.cs 实体高亮效果类: 轮廓边总控制类,该 ...
- 从身份证号提取生日并更新到生日字段中的SQL语句
1:根据身份证号 更新 生日字段 SQL update 学生信息 ,)+,)+,) 2:根据身份证号 更新 性别字段 SQL update 学生信息 set 性别='男' and substring( ...
- PC端写的API接口和手机端APP联合调试
一.遇到问题的情况:项目框架:asp.net MVC5 ,写的给手机端调用的API接口. 二.自己在本地 IIS上部署项目,在手机端的请求服务器上把地址和端口换上本地部署的,如图所示 三.用管理员的身 ...
- 用C#简单实现的36进制转换代码
private const string initValue = "A0000001"; private static string cs = "0123456789AB ...
- Development 编程规范
{ 命名规范类命名 1)所有的类名,接口名(Protocol)均以大写字母开头,多单词组合时,后面的单词首字母大写. 类,接口名必须是有意义的,切忌使用中文拼音命名.另外所有类都要加标致前缀:“O ...
- 40 VSCode下.json文件的编写——(1) linux/g++ (2).json中参数与预定义变量的意义解释
0 引言 转入linux/VSCode编程之后,迫切了解到有必有较为系统地学习一下VSCode中相关配置文件的写法.下面将分为 linux/g++编译指令..json文件关键词/替换变量的意义.编译链 ...
- NX二次开发-UFUN体找面函数UF_MODL_ask_body_faces
NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_obj.h> #include <u ...