配置中心 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 是用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持, ...
随机推荐
- PHP类知识----foreach
- 运行一次node服务后,再次运行报错
由于工作内容在git上,而系统又是window,大家知道,window自带的终端是不能进行git操作的,所以下载了一个git进行代码的更新提交. 我在git上运行了node服务后,由于不同的项目,我需 ...
- Kafka、RabbitMQ、RocketMQ等消息中间件的介绍和对比(转)
前言在分布式系统中,我们广泛运用消息中间件进行系统间的数据交换,便于异步解耦.现在开源的消息中间件有很多,前段时间产品 RocketMQ (MetaQ的内核) 也顺利开源,得到大家的关注. 概念MQ简 ...
- CentOS 安装oracle client
下载Oracle Client 1.通过下载地址下载 下载地址:https://www.oracle.com/database/technologies/instant-client/linux-x8 ...
- 51 Nod 1100 斜率最大
1100 斜率最大 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注 平面上有N个点,任意2个点确定一条直线,求出所有这些直线中,斜率最大的那条直线 ...
- FZU 2231 平行四边形数
FZU - 2231 平行四边形数 题目大意:给你n个点,求能够组成多少个平行四边形? 首先想到的是判断两对边平行且相等,但这样的话得枚举四个顶点,或者把点转换成边然后再枚举所有边相等的麻烦,还不好 ...
- python播放音乐
最近一直想实现使用Python播放音乐的功能,找了百度上的好多博客,要不就只能播放wav格式的,要不播放mp3格式的但无法在Linux系统下使用的,或者只能在Python2的情况下播放的,写的都不符合 ...
- Thread(简单使用)
/***thread.c***/#include<stdio.h> #include<stdlib.h> #include<pthread.h> void prin ...
- 【译】XMLHttpRequest和Fetch, 谁最适合AJAX?
原文地址:https://www.sitepoint.com/xmlhttprequest-vs-the-fetch-api-whats-best-for-ajax-in-2019/ 目录 从AJAX ...
- linux 查看系统性能
1. 查看内存和CPU信息 cat /proc/cpuinfo cpu信息 cat /proc/meminfo |grep MemTotal 内存信息 查看物 ...