spring cloud(三) config
spring cloud 配置中心 config 搭建过程
1.搭建config-server 服务端
1.1. 新建boot工程 pom引入依赖
1.2.启动类添加注解@EnableConfigServer
1.3 application.properties添加配置
1.4 配置验证
远端仓库配置文件
页面读取查看
2.配置读取客户端
2.1 pom引入依赖
2.2 添加bootstrap.properties 配置文件
由于spring boot 配置读取顺序,将config相关配置写在application.properties 无效,spring boot 会自动连接默认的localhost:8888 读取配置中心 。所以新建bootstrap.properties配置,bootstrap.properties的优先级大于application.properties。
bootstrap.properties
2.3 读取配置,使用验证
程序代码
调用程序获取
项目github 地址 https://github.com/yongxiangliu123/SpringCloud



浙公网安备 33010602011771号