You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"name":"config-client","profiles":["dev"],"label":null,"version":"faf3340174cd0bf9b12853c67f655a82482711b1","state":null,"propertySources":[{"name":"https://github.com/do9len/SpringcloudConfig//respo/config-client-dev.properties","source":{"name":"hugeterry version 1","democonfigclient.message":"hello spring io"}}]}
分布式配置中心
构建config Server
在已有工程下创建module,起名为scconfig-server
config Server(配置中心) new ->moudle ->Spring initialir->next 填写moudle名->cloud config->✅config server
在application启动类增加注解@ EnableConfigServer,开启配置服务器
配置文件
配置信息说明:
spring.cloud.config.server.git.uri:git仓库地址spring.cloud.config.server.git.searchPaths:仓库路径spring.cloud.config.label:仓库分支spring.cloud.config.server.git.username:访问git仓库的用户名 公开仓库可不填spring.cloud.config.server.git.password:访问git仓库的用户密码 公开仓库可不填启动,访问http://localhost:8555/hugeterry/dev ,返回如下报文
访问http://localhost:8555/config-client/dev ,返回如下报文
访问http://localhost:8555/config-client-dev.properties 或http://localhost:8555/master/config-client-dev.properties ,返回如下报文
配置服务中心可以从远程程序获取配置信息,http请求地址和资源文件映射如下:
application 配置文件中name,或者根据文件名获取
label 分支
profile 为测试环境,一般有如下选项
构建config client
在已有工程下创建module,起名为scconfig-client
new ->moudle ->Spring initialir->next 填写moudle名->cloud config->✅config client
增加起步依赖
spring-boot-starter-web增加配置文件bootstrap.properties:
关于参数的意义与上文链接映射相似,这里多出一个
spring.cloud.config.uri为配置服务中心在application启动类里增加“/c”API,获取git文件里name的值
访问http://localhost:8551/c 返回如下报文
这个过程的调用关系为 scconfigclient->scconfigserver->github