服务端配置文件:bootstrap.yml,关键配置
spring:
application:
name: config-server
#config-server配置
cloud:
config:
server:
git:
# gitlab需要加.git后缀
uri: http://ip:port/root/config-source.git
username: root
password: 密码
# 访问ssh私钥口令—git,在创建秘钥的时候回要求输入此密码,不输入的话跟password一样
passphrase: 密码
# 多个用“,”隔开
search-paths: user-center,config-client,test-client
# 忽略SSL证书校验
skip-ssl-validation: true
# 指定svn目录下的某个文件夹作为配置仓库 默认为trunk,git默认是master,gitlab需要创建分支,idea中右下角,在提交资源配置文件时,先切换到对应的分支下(没有就先新增),再提交
default-label: config
bus:
trace:
enabled: true
enabled: true
#指定配置中心使用svn管理: subversion
profiles:
active: dev
#rabbitmq 配置
rabbitmq:
host: rabbit的ip地址
port: 5672
username: 用户名
password: 密码
客户端配置文件:bootstrap.yml,关键配置
spring:
application:
name: config-client
cloud:
config:
# 开启通过服务来访问Config Server的功能
discovery:
enabled: true
service-id: config-server
# 可以写多个,中间用“,”隔开
name: config-client
# 环境名,对应前配置文件中的{profile}部分
profile: dev
# 启动失败时能够快速响应
fail-fast: true
# 指定分支
label: config
bus:
# 将不同的项目在bus中区分
id:
s
p
r
i
n
g
.
a
p
p
l
i
c
a
t
i
o
n
.
n
a
m
e
:
{spring.application.name}:
spring.application.name:{spring.cloud.config.profile}?{random.value}
trace:
enabled: true
enabled: true
inetutils:
# 可用ip地址段表示,本地测试用
preferred-networks: [‘172’]
rabbitmq:
host: ip
port: 5672
username: root
password: 密码
#actuator健康检查
management:
endpoints:
web:
exposure:
include: “*” #暴露所有端点 默认是info和health
endpoint:
health:
show-details: always #默认是never
gitlab中的webhook地址:
http://config-server的ip:端口/monitor
push events中我录入了*,表示刷新所有分支
启用:SSL verification
手工刷新:
postman中post方式调用http://config-server端的ip:端口/actuator/bus-refresh