SpringCloud微服务实战(六)-统一配置中心
2018-07-03 本文已影响120人
紫霞等了至尊宝五百年
1 统一配置中心概述
为什么需要统一配置中心
![](https://img.haomeiwen.com/i4685968/f0f3d011837db423.png)
![](https://img.haomeiwen.com/i4685968/643d79fbceb00776.png)
2 Config Server
![](https://img.haomeiwen.com/i4685968/0fad7b5dca0b3a38.png)
![](https://img.haomeiwen.com/i4685968/7e711c92c0453468.png)
直接运行报错,因为会从 git拉取配置文件
![](https://img.haomeiwen.com/i4685968/9cc4e0bef5893fae.png)
在 Git 建立新仓库存放配置文件
![](https://img.haomeiwen.com/i4685968/420d649f55c1b7a0.png)
![](https://img.haomeiwen.com/i4685968/7852959592bd1918.png)
![](https://img.haomeiwen.com/i4685968/5b7951651045396f.png)
![](https://img.haomeiwen.com/i4685968/423951f19ae6b435.png)
![](https://img.haomeiwen.com/i4685968/5814672f3cb205c4.png)
若故意将 yml 格式写错,则会报错
![](https://img.haomeiwen.com/i4685968/489cc6a257433f45.png)
两种配置文件访问路径
/{name}-{profiles}.yml
/{label}/{name}-{profiles}.properties]
name 服务名
profiles 环境
label 分支( branch)
新建一个分支
![](https://img.haomeiwen.com/i4685968/6c4062f69c2a9b3e.png)
修改下配置文件,以示区别
![](https://img.haomeiwen.com/i4685968/264e6d807eb94200.png)
访问成功
![](https://img.haomeiwen.com/i4685968/38b3d9837b956ce7.png)
git默认存放路径
![](https://img.haomeiwen.com/i4685968/c91e79e187a22836.png)
亦可自定义路径
![](https://img.haomeiwen.com/i4685968/26a5431fa67a0b63.png)
3 Config Client
![](https://img.haomeiwen.com/i4685968/15bf14c76ab8ceb0.png)
![](https://img.haomeiwen.com/i4685968/f4c7b53b65e4a4c2.png)