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 ...
随机推荐
- 20155302 2016-2017-2 《Java程序设计》第3周学习总结
20155302 2016-2017-2 <Java程序设计>第3周学习总结 教材学习内容总结 两个基本的标准类:java.util.Scanner与java.math.BigDecima ...
- 20155306 《信息安全技术概论》实验二 Windows口令破解
20155306 <信息安全技术概论>实验二 Windows口令破解 [实验目的] 了解Windows口令破解原理 对信息安全有直观感性认识 能够运用工具实现口令破解 [实验人数] 每组1 ...
- KDTable如何添加合计行?
/** * 功能:添加合计行 * * @param table * 指定的KDTable * @param fields * 需要合计的列 */ public static void apendFoo ...
- Apache入门篇(四)之LAMP架构部署
一.LAMP解析 a: apachem: mariadb, mysqlp: php, perl, python 静态资源:静态内容:客户端从服务器获得的资源的表现形式与原文件相同:动态资源:通常是程序 ...
- Yii2 模块module笔记
包含内容: 使用GII新建module 建立子模块 在其他控制器中调用模块的操作(action) 1. 使用Gii工具新建module 注意模块的路径,我们没有写backend\modules\Art ...
- MSP430的JTAG接口和BSW接口
1.JTAG口,JTAG引脚如下定义: 单片机TCK——测试时钟输入,接仿真器7脚 单片机TDI——测试数据输入,接仿真器2脚 单片机TDO——测试数据输出,接仿真器1脚 单片机TMS——测试 ...
- vcruntime140.dll 丢失64位系统
1. 下载VC Redistributable for VS2015,网址https://www.microsoft.com/en-us/download/confirmation.aspx?id=4 ...
- SQL基本数据类型等
bit 类似C#中的bool类型 true/false int 整型 nvarchar 字符串类型 float 小数型 decimal(,) 小数型 (限制小数位数) dateti ...
- tp框架-------验证码
验证码我们一般很常见,在注册或登录时,都可以用的到,下面我们就来看看它的代码和用法 加验证码是为了防止表单攻击的一种方式,为了我们的程序更加的安全 在tp框架中它自带了一个验证码的类,我们先来看一下 ...
- Qt-QMl-自定义自己想要的TabView
上效果图 上实现源码,这里的代码都是来自Qt官方源码修改其中某一行内容 /* 作者:张建伟 时间:2018年4月8日 简述:自定义TabView,主要实现Tab和实现内容重叠,不在占用独立空间 该文件 ...