Spring Cloud Config 解决了在分布式场景下多环境配置文件的管理和维护。
好处:
1 集中管理配置文件
2 不同环境不同配置,动态化的配置更新
3 配置信息改变时,不需要重启即可更新配置信息到服务
config server:
1 使用gitee创建远程仓库,上传配置文件
2 搭建 config server 模块
3 导入 config-server 依赖
4 编写配置,设置 gitee 远程仓库地址
5 测试访问远程配置文件
config-parenttset com.itheima 1.0-SNAPSHOT 4.0.0 config-server org.springframework.cloud spring-cloud-config-server
server:port: 9527spring:application:name: config-server#spring cloud configcloud:config:server:# git的远程仓库地址git:uri: https://gitee.com/xxxx/xxxx.gitusername: xxxxxxpassword: xxxxxx///但是此块我直接访问github就访问失败 不知道为什么label: master #分支配置
config client:
1 导入 starter-config 依赖
2 配置config server 地址,读取配置文件名称等信息
3 获取配置值
4 启动测试
上一篇:Leetcode 第二天 20230315 python
下一篇:数据库系统概述