server端配置

POM文件

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>

配置文件

application.yml

server:
port: 8251

spring:
application:
name: config-server-bus
cloud:
config:
server:
git:
username: git userName
password: gitPassword
uri:git Url
search-paths: /spring-cloud-config
default-label: spring-cloud-config
bus:
trace:
enabled: true # 启用日志跟踪
rabbitmq: # rabbitmq的配置信息
host: localhost
port: 5672
username: guest
password: guest

management: # 管理端信息
endpoints:
web:
exposure:
include: bus-env,bus-refresh # 暴露端点
endpoint:
health:
show-details: always # 日志显示时机

client端配置

POM文件

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>

配置文件

bootstrap.yml

server:
port: 8081

spring:
rabbitmq: # Rabbit Mq 配置信息
host: localhost
port: 5672
username: guest
password: guest
profiles:
active: dev # 启动项目加载的配置文件类型
application:
name: config
cloud:
config:
uri: http://localhost:8251 # 配置服务器地址
name: ${spring.application.name} # 服务名称
profile: ${spring.profiles.active} # 那个类型的配置为文件 文件类型分为 dev test prod
bus:
trace:
enabled: true
management:
endpoints:
web:
exposure:
include: bus-env,bus-refresh
endpoint:
health:
show-details: always
refresh:
enabled: true

原来代码需要修改的

需要在原来的组件类上加该注解@RefreshScope表示这个类是刷新作用域,其他注解保持不变。

组件类定义:使用了类级注解@RestController@Controller@Service@Repository@Component@Configuration的类

注意:服务端和客户端都需要依赖amqp的依赖。

Spring Cloud Config 使用Bus的动态配置中心的更多相关文章

  1. Spring Cloud Config、Apollo、Nacos配置中心选型及对比

    Spring Cloud Config.Apollo.Nacos配置中心选型及对比 1.Nacos 1.1 Nacos主要提供以下四大功能 2.Spring Cloud Config 3.Apollo ...

  2. Spring cloud config client获取不到配置中心的配置

    Spring cloud client在配置的时候,配置文件要用 bootstrap.properties 贴几个说明的链接.但是觉得说的依然不够详细,得空详查. 链接1 链接2 链接3 原文地址:h ...

  3. 9.Spring Cloud Config统一管理微服务配置

    Spring Cloud Config统一管理微服务配置 9.1. 为什么要统一管理微服务配置 9.2. Spring Cloud Config简介 Spring Cloud Config为分布式系统 ...

  4. spring boot 2.0.3+spring cloud (Finchley)6、配置中心Spring Cloud Config

    https://www.cnblogs.com/cralor/p/9239976.html Spring Cloud Config 是用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持, ...

  5. Spring Cloud学习笔记【九】配置中心Spring Cloud Config

    Spring Cloud Config 是 Spring Cloud 团队创建的一个全新项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持,它分为服务端与客户端两个部分.其中服务端 ...

  6. 一起来学Spring Cloud | 第七章:分布式配置中心(Spring Cloud Config)

    上一章节,我们讲解了服务网关zuul,本章节我们从git和本地两种存储配置信息的方式来讲解springcloud的分布式配置中心-Spring Cloud Config. 一.Spring Cloud ...

  7. Spring Cloud学习笔记【十】配置中心(消息驱动刷新配置)

    上一篇中讲到,如果需要客户端获取到最新的配置信息需要执行refresh,我们可以利用 Webhook 的机制每次提交代码发送请求来刷新客户端,当客户端越来越多的时候,需要每个客户端都执行一遍,这种方案 ...

  8. Spring Cloud Alibaba 整合 Nacos 实现服务配置中心

    在之前的文章 <Nacos 本地单机版部署步骤和使用> 中,大家应该了解了 Nacos 是什么?其中 Nacos 提供了动态配置服务功能 一.Nacos 动态配置服务是什么? 官方是这么说 ...

  9. Spring Cloud系列(六):配置中心

    在使用Spring Boot的时候,我们往往会在application.properties配置文件中写一些值,供应用使用,这样做的好处是可以在代码中引用这些值,当这些值需要作出修改的时候,可以直接修 ...

随机推荐

  1. delphi三层架构(使用SATRDA改造,客户端代码不变)

    我们的delphi程序很多是以前开发的,采用典型的CS架构,由程序直接连接数据库.现在需要改成在外网可以直接操作软件.先把数据库搬到了阿里云上,测试发现直接连数据库和VPN连接测试速度很慢,直连还容易 ...

  2. 基于MATLAB的滤波算法

    目前比较经典的图像去噪算法主要有以下三种: 均值滤波:也称线性滤波,主要思想为邻域平均法,即用几个像素灰度  的平均值来代替每个像素的灰度.有效抑制加性噪声,但容易引起图像模糊,  可以对其进行改进, ...

  3. POJ3087 Shuffle'm Up —— 打表找规律 / map判重

    题目链接:http://poj.org/problem?id=3087 Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Sub ...

  4. MYSQL初级学习笔记二:数据表相关操作及MySQL存储引擎!(视频序号:初级_5,7-22|6)

    知识点三:数据表相关操作(5,7-22) --------------------------------整型--------------------------------- --测试整型 CREA ...

  5. html5--6-55 动画效果-关键帧动画

    html5--6-55 动画效果-关键帧动画 实例 @charset="UTF-8"; div{ width: 150px; height: 150px; font-size: 2 ...

  6. Silverlight中使用MVVM(3)

    Silverlight中使用MVVM(1)--基础 Silverlight中使用MVVM(2)—提高 Silverlight中使用MVVM(3)—进阶 Silverlight中使用MVVM(4)—演练 ...

  7. Android自定义控件实现带有清除按钮的EditText

    首先声明我也是参考了别人的思路,只是稍微做了下修改,增加显示密码与隐藏密码,没有输入字符串时让EditText进行抖动,废话少说这里附上效果图 效果很赞有木有 那么怎么实现这种效果呢?那就跟着我一起来 ...

  8. Cascaded pose regression

    最近再看face alignment的相关文章,目前比较流行的算法都是基于(Cascaded pose regression,CPR)[1]的框架上做的,该算法之所以流行的原因是简单高效.CPR分为训 ...

  9. CS231n 2016 通关 第二章-KNN

      课程内容全纪录: 1.讲解图像分类的难点 1.光照强度 2.主体变形 3.主体与背景咬合 4.主体与背景相接近 5.同类别间存在区别 2.KNN 1.最近邻算法 2.Knn 3.hyperpara ...

  10. SPOJ FIBOSUM && FIBOSUM2

    Fibonacci数列定义为 $$f_n = f_{n-1}+f_{n-2}, \text{以及初值}f_0=0, f_1=1.$$ 本文之讨论,皆在模$10^9+7$意义下. FIBOSUM 给定$ ...