阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

用Git配置”配置服务器”

142次阅读
没有评论

共计 1734 个字符,预计需要花费 5 分钟才能阅读完成。

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

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

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

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

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 文件中写入以下内容:

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

{"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

{"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

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

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-06-06发表,共计1734字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中