Spring Cloud Config
1.config服务端配置
1.1 引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
1.2 配置项application.yml
spring:
cloud:
zookeeper:
connect-string: 192.168.220.128:2181
config:
server:
git:
uri: https://gitee.com/lm970585581/cloud-config
username: lm970585581
password: ***** #密码
1.3 启动类配置
@EnableConfigServer 启用服务配置
测试说明:
/{label}/{name}-{profiles}.yml
/{name}-{profiles}.yml
name git的文件名称不包括后缀
profiles 环境
label 分支(branch)
2、客户配置:provider应用
2.1 引入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
2.2 配置项bootstrap.yml
spring:
cloud:
zookeeper:
connect-string: 192.168.220.128:2181
config:
discovery:
enabled: true
service-id: config #配置服务项目名
profile: dev
application:
name: provider
Spring Cloud Bus 手动实现刷配置(不重启项目情况下)
1.安装RabbitMQ
详见:https://www.cnblogs.com/lm970585581/p/9873391.html
2.配置端引入依赖
<!--加入spring cloud bus + rabbitmq-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
3.配置端配置application.yml
spring:
rabbitmq:
port: 5672
host: 192.168.220.128
username: test
password: root
management:
endpoints:
web:
exposure:
include: '*' # 开启所有配置url
4.在controller上启用读取刷新数据注解@RefreshScope
此时,当git上的配置修改后,配置应用的内容会同步修改
客户端应用的配置需要手动使用Post方式刷新,即可同步修改,无需重启服务,格式如下:地址是配置应用的地址
http://localhost:8080/actuator/bus-refresh
Spring Cloud Bus 实现自动刷配置(不重启项目情况下)+WebHooks
加入依赖
<!--添加支持gitlab,github,gitee webhooks依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
想办法把自己机器变为服务器,可以使用netaap
在gitee里面配置webhook
通过/monitor 接口回调目标服务对应的服务
注意:自动刷新方式有BUG存在,可能会失败,等官方修复吧!
具体实例详见:https://gitee.com/lm970585581/cloud-config
码云上的配置信息

Spring Cloud Config的更多相关文章
- Spring Cloud面试题万字解析(2020面试必备)
1.什么是 Spring Cloud? Spring cloud 流应用程序启动器是 于 Spring Boot 的 Spring 集成应用程序,提供与外部系统的集成.Spring cloud Tas ...
- 什么是 Spring Cloud Bus?我们需要它吗?
考虑以下情况:我们有多个应用程序使用 Spr ng Cloud Config 读取属性,而S ring Cloud Config 从GIT 读取这些属性. 下面的例子中多个员工生产者模块从 Employe ...
- Spring Cloud Greenwich 新特性和F升级分享
2019.01.23 期待已久的Spring Cloud Greenwich 发布了release版本,作为我们团队也第一时间把RC版本替换为release,以下为总结,希望对你使用Spring Cl ...
- Spring Cloud 学习 之 Spring Cloud Bus实现修改远程仓库后配置自动刷新
版本号: Spring Boot:2.1.3.RELEASE Spring Cloud:G版 开发工具:IDEA 搭建配置中心,这里我们搭建一个简单版的就行 POM: <?xml ...
- Kafka及Spring Cloud Stream
安装 下载kafka http://mirrors.hust.edu.cn/apache/kafka/2.0.0/kafka_2.11-2.0.0.tgz kafka最为重要三个配置依次为:broke ...
- Microservices Reference Architecture - with Spring Boot, Spring Cloud and Netflix OSS--转
原文地址:https://www.linkedin.com/pulse/microservices-reference-architecture-spring-boot-cloud-anil-alle ...
- Building microservices with Spring Cloud and Netflix OSS, part 2
In Part 1 we used core components in Spring Cloud and Netflix OSS, i.e. Eureka, Ribbon and Zuul, to ...
- Spring cloud项目实践(一)
链接地址:http://sail-y.github.io/2016/03/21/Spring-cloud%E9%A1%B9%E7%9B%AE%E5%AE%9E%E8%B7%B5/ 什么是Spring ...
- 【译文】用Spring Cloud和Docker搭建微服务平台
by Kenny Bastani Sunday, July 12, 2015 转自:http://www.kennybastani.com/2015/07/spring-cloud-docker-mi ...
随机推荐
- [arc082F]Sandglass
Description 传送门 Solution 这题是真的666啊... 以下是本题最关键最关键的结论:如果ai<=aj,则在某个时间t,前者的A中沙子克数(记为t(ai))一定大于等于t(a ...
- 北京Uber优步司机奖励政策(4月13日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- lnmp环境搭建(centos6.9+mysql5.7+php7.1+nginx1.10)
安装前准备:CentOS 6.9 64位 最小化安装 yum install -y make gcc gcc-c++ perl zlib-devel libaio libpng libpng-deve ...
- Migrating to WebSphere 9
Migrating to WebSphere 9 Make a migration plan Requirements Migrate WebSphere profiles into the new ...
- jenkins升级为2.134
由于前面装的jenkins版本为2.130版本,昨天(2018.7.26)发现了两个jenkins的漏洞,影响范围为:Jenkins weekly 2.132 以及更早的版本.Jenkins LTS ...
- idea下增加scala
1 idea工具下,下载scala插件 2 idea下新建scala工程 File——New——module 如果按照上图,设置后点击下载,出现下图下载过慢情况下, 这里我选择了等待,大概等了半小时才 ...
- python的30个编程技巧
1.原地交换两个数字 x, y =10, 20 print(x, y) y, x = x, y print(x, y) 10 20 20 10 2.链状比较操作符 n = 10 print(1 &l ...
- v-for 指令
JS部分: var app = new Vue({ el: "#app", data() { return { list: [1, 2, 3, 4], objList: [ { i ...
- Tensorflow - Implement for a Convolutional Neural Network on MNIST.
Coding according to TensorFlow 官方文档中文版 中文注释源于:tf.truncated_normal与tf.random_normal TF-卷积函数 tf.nn.con ...
- 二分图最大匹配模版 m√(n) 复杂度
周大爷在比赛中搜到的黑科技二分图模版,复杂度为m√(n): 注意:点的序号要从0开始! 需要把nx,ny都赋值为n(点数) ; *; struct Edge { int v; int next; } ...