Spring Cloud Config 分布式配置中心使用教程 Spring Cloud Config 分布式配置中心使用教程

Spring Cloud Config 分布式配置中心使用教程

一、简介

在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件。

在Spring Cloud中,有分布式配置中心组件spring cloud config ,它支持配置服务放在配置服务的内存中(即本地),也支持放在远程Git仓库中。

在spring cloud config 组件中,分两个角色,一是config server,二是config client。

步骤:

1、用自己的账号在github上 创建一个仓库,如:springcloud-config

2、本地创建git仓库目录:E:./myspringcloud-config

克隆工程到本地:

git clone https://github.com/<用户昵称>/springcloud-config.git

3、新增配置文件:application.yml

添加内容:

扫描二维码关注公众号,回复: 4163245 查看本文章
spring:
  profiles:
    active:
    - dev
---
spring:
  profiles: dev     #开发环境
  application: 
    name: microservicecloud-config-atguigu-dev
---
spring:
  profiles: test   #测试环境
  application: 
    name: microservicecloud-config-atguigu-test
#  请保存为UTF-8格式

猜你喜欢

转载自www.cnblogs.com/gaogaoyanjiu/p/9837168.html