spring cloud config配置记录
1. spring cloud config配置记录
1.1. pom
<!-- 分布式配置中心 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
1.2. 创建bootstrap.yml
- 配置eureka和config相关配合
spring:
application:
name: carer
cloud:
config:
uri: http://i.xxx.com:8888
profile: dev
username: dev
password: xxxx
eureka:
instance:
appname: carer-test
prefer-ip-address: true
client:
serviceUrl:
defaultZone: http://dev:xxxx@i.tzxylao.com:8761/eureka/
- 其他配置全部移至application-dev.properties和application.pro.properties
1.3. 配置刷新
1.3.1. 添加注解
- 添加@RefreshScope注解
- example
@Component
@RefreshScope
public class SysConfig {
@Value("${openTradeTest}")
private String openTradeCode;
@Value("${sysId}")
private String sysId;
@Value("${authUrl}")
private String authUrl;
public String getOpenTradeCode() {
return openTradeCode;
}
public void setOpenTradeCode(String openTradeCode) {
this.openTradeCode = openTradeCode;
}
public String getSysId() {
return sysId;
}
}
1.3.2. 添加pom
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
1.3.3. 配置
spring.rabbitmq.virtual-host=xxx
spring.rabbitmq.addresses=localhost:5672
spring.rabbitmq.username=xxx
spring.rabbitmq.password=***
上述两个步骤在服务端和客户端都得做
1.3.4. 刷新
- 调用 localhost:8888/bus/refresh 实现连接同一个服务的所有相同客户端配置刷新
1.4. 自动刷新
1.4.1. gitlab上配置

2. 最后记得add Webhook按钮点下添加
3. 因为设置了登录密码,填写地址的时候,可以这样
http://username:password@localhost:8888/bus/refresh
spring cloud config配置记录的更多相关文章
- Spring Cloud Config 配置刷新
客户端进行刷新操作. 1.添加 actuator包,这样 /refresh url才处于可用状态. <dependency> <groupId>org.springframew ...
- 跟我学SpringCloud | 第七篇:Spring Cloud Config 配置中心高可用和refresh
SpringCloud系列教程 | 第七篇:Spring Cloud Config 配置中心高可用和refresh Springboot: 2.1.6.RELEASE SpringCloud: Gre ...
- 微服务SpringCloud之Spring Cloud Config配置中心Git
微服务以单个接口为颗粒度,一个接口可能就是一个项目,如果每个项目都包含一个配置文件,一个系统可能有几十或上百个小项目组成,那配置文件也会有好多,对后续修改维护也是比较麻烦,就和前面的服务注册一样,服务 ...
- 微服务SpringCloud之Spring Cloud Config配置中心服务化
在前面两篇Spring Cloud Config配置中心的博客中都是需要指定配置服务的地址url:spring.cloud.config.uri,客户端都是直接调用配置中心的server端来获取配置文 ...
- spring cloud --- config 配置中心 [本地、git获取配置文件]
spring boot 1.5.9.RELEASE spring cloud Dalston.SR1 1.前言 spring cloud config 配置中心是什么? 为了统一管理配 ...
- Spring Cloud Config 配置中心高可用
详细参见 <Spring Cloud 与 Docker微服务架构实战> p163-9.10 Spring Cloud Config 与 Eureka 配合使用 p163-9.12 Conf ...
- Spring Cloud Config 配置中心 自动加解密功能 jasypt方式
使用此种方式会存在一种问题:如果我配置了自动配置刷新,则刷新过后,加密过后的密文无法被解密.具体原因分析,看 SpringCloud 详解配置刷新的原理 使用 jasypt-spring-boot- ...
- Spring Cloud Config 配置中心
请将远程配置文件的格式写对: 比如使用 *.yml 或者 *.properties yml: testconfig: testvalue properties: testconfig=testvalu ...
- spring cloud config配置
参考: http://www.ityouknow.com/springcloud/2017/05/22/springcloud-config-git.html http://www.ityouknow ...
随机推荐
- Layui 写一个简单的后台页面
参考如下: 1.layui 官方文档 http://www.layui.com/doc/ 2.https://blog.csdn.net/huyanliang/article/details/7796 ...
- spring boot利用controller来测试写的类
我们在开发spring boot应用程序的时候,往往需要测试某个写好的类,但是在测试的时候发现不太好测试,用Junit等测试框架,总是会报一些问题,大致是找不到配置文件以及无法利用spring创建的对 ...
- Python第十六天 类的实例化
首先 , 先定义一个 简单的 Person 类 class Person: head = 1 ear = 2 def eat(self): print('吃饭') 关于什么是类, 定义类, 类对象,类 ...
- linu输出重定向
1.tee命令 ls | tee filename #若出现Permission Denied使用下面 ls | sudo tee filename #清空filename后重写 ls | sudo ...
- java基本类型的默认值
基本类型 默认值 取值范围 (最大/最小) 字节数 二进制位数 byte 0 127(2^7-1) -128(-2^7) 1byte 8bit short 0 32767(2^15 - 1) -327 ...
- [Java算法] -- 1. 常用排序之冒泡排序和选择排序
使用Java语言实现冒泡排序和选择排序 推荐一个数据结构可视化的网站:http://zh.visualgo.net/zh (暂时访问不了) 对排序不太熟悉的朋友,建议去上面的网站学习一下,你将会发现一 ...
- MySQL 多表结构的创建与分析
=====================多对一===================== create table press( id int primary key auto_increment, ...
- Python开发——11.异常及异常处理
一.异常 1.定义 异常及时程序运行时发生错误的信号 2.种类 异常分为语法错误和逻辑错误,语法错误在程序执行之前就应该改正. 常用异常 AttributeError 试图访问一个对象没有的树形,比如 ...
- Python 获取车票信息
提示:该代码仅供学习使用,切勿滥用!!! 先来一个git地址:https://gitee.com/wang_li/li_wang 效果图: 逻辑: 1.获取Json文件的内容 2.根据信息生成URL ...
- azure cosmos db (mongo DB)
使用.net mongo的操作类操作azure(微软云)cosmosdb时,发现在做delete的操作的时候可以传一个文档对象,但是最后这个文档会解析成具体的sql语句,而当文档特别大时这样就出先了转 ...