1、配置中心图解
2、什么是 Spring Cloud Config
Spring Cloud Config 是一个分布式配置中心解决方案,它为分布式系统提供了外部化配置的集中式管理功能,它包含Config Server 和 Config Client。
3、在Maven项目下创建Spring Cloud Config 模块
4、勾选 Config Server 和 Eureka Discovery Client
注:因为需要将 spring-cloud-config-server 注册到 Eureka Server 中,因此需要勾选 Eureka Discovery Client
5、在 gitee 上新建仓库
仓库地址:https://gitee.com/xxxx/spring-cloud-congfig-server.git
按照仓库提供的命令对仓库进行初始化
初始化完成后,创建一个配置文件,用于存放配置信息
6、添加配置信息 和 注解
7、启动 spring-cloud-congfig-server 模块
访问 http://localhost:8083/user-define.properties
,成功地返回了配置信息
访问 http://localhost:8083/user-define.yaml
,成功地返回 yaml 格式的配置信息
在日志中我们可以看到配置文件加载到了本地的C盘中的临时目录下
我们也可以在配置文件中修改配置文件加载的路径
修改后的文件加载路径
8、将配置文件路径配置在本地