一、Config环境搭建
二、Bus相关依赖
配置中心
server:
port: 3344
spring:
application:
name: cloud-config-center
cloud:
config:
server:
git:
uri: https://github.com/hqzhen/springcloud-config.git
## 搜索目录
search-paths:
- springclpud-config
### 读取分支
label: master
## rabbitmq相关配置,
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
eureka:
instance:
hostname: cloud-config-service
client:
#表示是否将自己注册进Eureka Server 默认为true
register-with-eureka: true
#是否从Eureka Server抓取已有的注册信息,默认为true。单节点无所谓。集群必须设置为true才能配合ribbon使用负载均衡
fetch-registry: true
service-url:
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/
##暴露刷新配置的端点
management:
endpoints:
web:
exposure:
include: 'bus-refresh'
客户端
server:
port: 3355
spring:
application:
name: cloud-config-client
cloud:
## Config客户端配置
config:
#分支名称
label: master
#配置文件名称
name: config
#读取文件后缀
profile: dev
uri: http://localhost:3344 #远程配置中心地址
## rabbitmq相关配置
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
eureka:
instance:
hostname: cloud-config-client
client:
#表示是否将自己注册进Eureka Server 默认为true
register-with-eureka: true
#是否从Eureka Server抓取已有的注册信息,默认为true。单节点无所谓。集群必须设置为true才能配合ribbon使用负载均衡
fetch-registry: true
service-url:
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/
# 自定义属性
config:
info: test
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: "*"
server:
port: 3366
spring:
application:
name: cloud-config-client
cloud:
## Config客户端配置
config:
#分支名称
label: master
#配置文件名称
name: config
#读取文件后缀
profile: dev
uri: http://localhost:3344 #远程配置中心地址
## rabbitmq相关配置,
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
eureka:
instance:
hostname: cloud-config-client
client:
#表示是否将自己注册进Eureka Server 默认为true
register-with-eureka: true
#是否从Eureka Server抓取已有的注册信息,默认为true。单节点无所谓。集群必须设置为true才能配合ribbon使用负载均衡
fetch-registry: true
service-url:
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/
# 自定义属性
config:
info: test
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: "*"
三、启动项目测试
1)、启动微服项目
2)、检查ribbitmq
3)、检查修改前访问客户端
github默认配置
客户端当前读取的配置
4)、修改配置信息测试配置中心通过bus动态广播
修改配置
刷新配置中心广播到所有服务
5)、再次检查客户端是否全部刷新