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 ...
随机推荐
- centos 防火墙端口开放
开放端口 永久的开放需要的端口 sudo firewall-cmd --zone=public --add-port=3000/tcp --permanent sudo firewall-cmd -- ...
- [精华][推荐]CAS SSO单点登录服务端客户端学习
1.通过下载稳定版本的方式下载cas的相关源码包,如下: 直接选择4.2.1的稳定代码即可 2.我们项目中的版本版本使用maven apereo远程库去下载 通过远程maven库下载cas-serve ...
- WebApi 增加身份验证 (OAuth 2.0方式)
1,在Webapi项目下添加如下引用: Microsoft.AspNet.WebApi.Owin Owin Microsoft.Owin.Host.SystemWeb Microsoft.Owin.S ...
- ASP.NET Core使用EntityFrameworkCore CodeFrist
1,安装环境: 如果是VS2015,确保已经升级至 update3或以上 .net core sdk (https://www.microsoft.com/net/download/core) vs2 ...
- JavaWeb(一)-Servlet中的Config和Context
一.ServletConfig对象 1.1获取一个servletConfig对象 1)通过初始化方法获得一个servletconfig 2)通过继承父类(GenericServlet.)得到一个ser ...
- Desktop Central 的移动设备管理功能
Desktop Central 的移动设备管理功能1.移动应用程序管理设备管理不会仅仅只是配置策略.检索资产信息和保护设备.应用程序管理与设置员工的移动设备一样重要.使用 Desktop Centre ...
- 更适用于JavaScript的设计模式:面向委托的设计,了解一下?(下)
先来看一下传统的面向类式的写法: function Foo(name) { this.name = name; } Foo.prototype.sayName = function() { conso ...
- WPF一组Radio与enum绑定
工作中用到了一组RadioButton对应一组数据的情况,这个时候最好能将一组RadioButton绑定Enum. 步骤 1.MyControl库中Type.cs中定义Enum namespace M ...
- mysql 截取替换某个字符串
SELECT m.content,o.order_price,o.id,m.id FROM scp_home_msg m INNER JOIN scp_order o ON m.link_id=o.i ...
- 《笔记篇》非JS方法跳转到一个新页面,主要防止客户端禁止浏览器JS以后的跳转异常
用非JS方法打开一个新页面,主要防止客户端禁止浏览器JS以后的跳转失效 <meta http-equiv="refresh" content="0; url=htt ...