前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >用Git配置”配置服务器”

用Git配置”配置服务器”

作者头像
星哥玩云
发布2022-09-15 14:31:11
4.5K0
发布2022-09-15 14:31:11
举报
文章被收录于专栏:开源部署开源部署

1、用Git配置"配置服务器"

1.1、在Git仓库中创建配置文件

1.1.1、在本地新建两个配置文件"config-dev.properties"和"config-pro.properties"

在config-dev.properites文件中写入以下内容:

代码语言:javascript
复制
app.version=dev
message=Spring Cloud Config
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
server.port=50028

在config-pro.properties文件中写入以下内容:

代码语言:javascript
复制
app.version=pro
message=Spring Cloud Config
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
server.port=50029
1.1.2、上传新建的两个配置文件到自己的Git仓库地址

1.2、读取配置信息

1.2.1、访问:http://localhost:50027/config/dev
代码语言:javascript
复制
{"name":"config","profiles":["dev"],"label":null,"version":"00f8179acc9ad109abc114309d8e46a0b032aa14","state":null,"propertySources":[{"name":"https://github.com/lingfengxeon/spring-config/config-dev.properties","source":{"app.version":"dev","message":"Spring Cloud Config","spring.rabbitmq.host":"localhost","spring.rabbitmq.port":"5672","spring.rabbitmq.username":"guest","spring.rabbitmq.password":"guest","server.port":"50028"}}]}
1.2.2、访问:http://localhost:50027/config/pro
代码语言:javascript
复制
{"name":"config","profiles":["pro"],"label":null,"version":"00f8179acc9ad109abc114309d8e46a0b032aa14","state":null,"propertySources":[{"name":"https://github.com/lingfengxeon/spring-config/config-pro.properties","source":{"app.version":"pro","message":"Spring Cloud Config","spring.rabbitmq.host":"localhost","spring.rabbitmq.port":"5672","spring.rabbitmq.username":"guest","spring.rabbitmq.password":"guest","server.port":"50029"}}]}
1.2.3、读取Config Server的配置信息

访问:http://localhost:50027/config-dev.properties

代码语言:javascript
复制
app.version: dev
message: Spring Cloud Config
server.port: 50028
spring.rabbitmq.host: localhost
spring.rabbitmq.password: guest
spring.rabbitmq.port: 5672
spring.rabbitmq.username: guest

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、用Git配置"配置服务器"
    • 1.1、在Git仓库中创建配置文件
      • 1.1.1、在本地新建两个配置文件"config-dev.properties"和"config-pro.properties"
      • 1.1.2、上传新建的两个配置文件到自己的Git仓库地址
    • 1.2、读取配置信息
      • 1.2.1、访问:http://localhost:50027/config/dev
      • 1.2.2、访问:http://localhost:50027/config/pro
      • 1.2.3、读取Config Server的配置信息
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档