首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >SpringCloud-Config 配置中心原理

SpringCloud-Config 配置中心原理

作者头像
磊叔的技术博客
发布于 2025-06-07 08:16:55
发布于 2025-06-07 08:16:55
12200
代码可运行
举报
运行总次数:0
代码可运行

本篇可以配合《SpringCloud-配置中心 Config》来看,《SpringCloud-配置中心 Config》中是基于SOFABoot 来集成 Spring Cloud Config 的一个 demo 案例。

demo地址:www.glmapper.com,或点击下方阅读全文获取

在demo中,涉及到三个角色:

  • 配置中心服务端:为配置客户端提供对应的配置信息,配置信息的来源是配置仓库。应用启动时,会从配置仓库拉取配置信息缓存到本地仓库中。
  • 配置中心客户端:应用启动时从配置服务端拉取配置信息。
  • 配置仓库:为配置中心服务端提供配置信息存储,Spring Cloud Config 默认是使用git作为仓库的。

整体过程:

  • 环境部署之前,将所需的配置信息推送到配置仓库
  • 启动配置中心服务端,将配置仓库的配置信息拉取到服务端,配置服务端对外提供REST接口
  • 启动配置客户端,客户端根据 spring.cloud.config 配置的信息去服务器拉取相应的配置

服务端实现

配置中心服务端主要做了几件事情:连接配置仓库、拉取远程配置&本地缓存、对外提供API接口服务。

@EnableConfigServer 及配置类

注解 EnableConfigServer 可以开启应用服务对配置中心的支持。当开启之后,配置服务器就会在启动时进行自动配置。具体对应的配置类是 ConfigServerAutoConfiguration,然后又在 ConfigServerAutoConfiguration 这个配置类中引入了其他很多配置类。如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Configuration
@ConditionalOnBean({Marker.class})
@EnableConfigurationProperties({ConfigServerProperties.class})
@Import({EnvironmentRepositoryConfiguration.class, CompositeConfiguration.class, ResourceRepositoryConfiguration.class, ConfigServerEncryptionConfiguration.class, ConfigServerMvcConfiguration.class})
public class ConfigServerAutoConfiguration {
    public ConfigServerAutoConfiguration() {
    }
}
  • EnvironmentRepositoryConfiguration: 环境变量存储相关的配置类
  • CompositeConfiguration:组合方式的环境仓库配置类
  • ResourceRepositoryConfiguration:资源仓库相关的配置类
  • ConfigServerEncryptionConfiguration:加密断点相关的配置类
  • ConfigServerMvcConfiguration:对外暴露的MVC端点控制器的配置类

无论是 Spring Cloud 自身提供的默认实现 git ,还是 zk,或者 apollo ;基本思路都是在程序启动时将远端配置拉取到本地作为环境变量来使用,但这些是针对客户端角度来说的。Spring Cloud Config Server 因为其本身是以服务端存在,所以 Config Server 本身的实现思路也值得后面开发借鉴。

对于服务端来说,其基本职责就是能够将具体存储中的配置信息先拿到,然后提供出 API 供客户端来调用。下面从ConfigServerAutoConfiguration 中 import的这些配置类来具体看下实现。

EnvironmentRepositoryConfiguration

EnvironmentRepositoryConfiguration 是环境变量存储相关的配置类,它本身也提供了很多实现:

上图中可以看到,环境配置仓库支持的有JDBC、SVN、本地文件系统、Git等等。这些对不同环境仓库的支持,在实现上基本都差不多,下面以默认提供的方式git来分析。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Configuration
@Profile("git")
class GitRepositoryConfiguration extends DefaultRepositoryConfiguration {
}

GitRepositoryConfiguration 集成了 DefaultRepositoryConfiguration,这也说明了 Spring Cloud Config 默认使用的是Git。不同的配置类实现都会被标注一个@Profile,可以通过这个来激活相应的配置类;具体做法是在配置服务端的 application.properties(application.yml) 中来指定:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
spring.profile.active=git

没有设置就是默认使用 GIt。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Configuration
@ConditionalOnMissingBean(value = EnvironmentRepository.class, search = SearchStrategy.CURRENT)
class DefaultRepositoryConfiguration {
    @Autowired
    private ConfigurableEnvironment environment;

    @Autowired
    private ConfigServerProperties server;

    @Autowired(required = false)
    private TransportConfigCallback customTransportConfigCallback;

    @Bean
    public MultipleJGitEnvironmentRepository defaultEnvironmentRepository(
            MultipleJGitEnvironmentRepositoryFactory gitEnvironmentRepositoryFactory,
            MultipleJGitEnvironmentProperties environmentProperties) throws Exception {
        return gitEnvironmentRepositoryFactory.build(environmentProperties);
    }
}

DefaultRepositoryConfiguration 的 ConditionalOnMissingBean 可以知道,如果上下文中没有 EnvironmentRepository,那么就使用 DefaultRepositoryConfiguration。

MultipleJGitEnvironmentRepository

MultipleJGitEnvironmentRepository 是 Git 存储的具体实现类,下面是类图结构:

MultipleJGitEnvironmentRepository 的顶层接口是 EnvironmentRepository ,当然其他的实现也都是实现了这个接口的。另外一个需要关注的是 SearchPathLocator。

  • EnvironmentRepository:定义了获取指定应用服务环境信息的方法,返回一个Enviroment
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
public interface EnvironmentRepository {
    Environment findOne(String application, String profile, String label);
}

三个参数,application、profile、label;《SpringCloud-配置中心 Config》 中客户端部分有对这三个的参数的说明及使用方式,通过这三个参数可以具体定位到配置信息。

  • SearchPathLocator : 根据传入客户端应用信息,获取对应的配置环境文件的位置。代码见:SearchPathLocator。

SearchPathLocator 中有一个内部类 Locations ,Locdations中定义了应用服务配置存储信息。

除了这两个之外,还有一个 AbstractScmAccessor,这个抽象类里面定义了一些列与git存储相关的属性和方法。包括远程仓库的地址、账户、密码、ssh 私钥、本地仓库的地址等等。

SCM : 软件配置管理

AbstractScmEnvironmentRepository

AbstractScmEnvironmentRepository 实现了 AbstractScmAccessor 和 EnvironmentRepository ,主要就是EnvironmentRepository 中 findOne 的实现:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Override
    public synchronized Environment findOne(String application, String profile, String label) {
    //新建了一个本地仓库作为代理仓库来使用
  NativeEnvironmentRepository delegate = new NativeEnvironmentRepository(getEnvironment(),
                new NativeEnvironmentProperties());
    //获取本地仓库中指定应用的位置
        Locations locations = getLocations(application, profile, label);
        delegate.setSearchLocations(locations.getLocations());
      //根据这个路径搜索应用服务的配置信息
        Environment result = delegate.findOne(application, profile, "");
        result.setVersion(locations.getVersion());
        result.setLabel(label);
        return this.cleaner.clean(result, getWorkingDirectory().toURI().toString(),
                getUri());
    }

getLocations 是一个模板方法,Config Server中提供了三种实现:

分别是单 Git 仓库,多 Git 仓库和 Svn 仓库实现。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Override
    public synchronized Locations getLocations(String application, String profile,
            String label) {
        if (label == null) {
            label = this.defaultLabel;
        }
    // 获取最新的版本号
        String version = refresh(label);
    // 根据最新的版本号返回 Locations 定位到资源的搜索路径
        return new Locations(application, profile, label, version,
                getSearchLocations(getWorkingDirectory(), application, profile, label));
    }

refresh 方法做的作用就是刷新本地仓库的配置状态,这样就能保证每次都能拉取到最新的配置信息。下面来分析这个方法。

JGitEnvironmentRepository#refresh

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
public String refresh(String label) {
        Git git = null;
        try {
      // 创建一个git客户端
            git = createGitClient();
      // 是否需要执行 git pull
            if (shouldPull(git)) {
                FetchResult fetchStatus = fetch(git, label);
                if (deleteUntrackedBranches && fetchStatus != null) {
                    deleteUntrackedLocalBranches(fetchStatus.getTrackingRefUpdates(), git);
                }
                // 获取后checkout,这样我们就可以获得任何新的分支、tag等。
                checkout(git, label);
                tryMerge(git, label);
            }
            else {
                // 没有什么要更新,所以只是checkout和merge。
                // 合并是因为远程分支以前可能已经更新过
                checkout(git, label);
                tryMerge(git, label);
            }
            // 返回当前的版本
            return git.getRepository().findRef("HEAD").getObjectId().getName();
        }
        catch (Exception e) {
            // 异常处理
        }
        finally {
            // 关闭git
        }
    }

这个里面基本就是通过git客户端的一些操作。先是检查远程仓库的状态,然后判断本地仓库是否要执行刷新操作。如果有状态更新,比如新的提交时,Git客户端就会执行fetch,然后再进行merge,更新到本地仓库。

MultipleJGitEnvironmentRepository 多仓库的支持,实际上就是遍历了所有的仓库。其他仓库和单仓库是一样的。

客户端实现

Spring Cloud Config Client 没有像其他组件一样提供@EnableConfigClient注解,这里没有必要去标注是一个配置客户端,只要引入了spring-cloud-config-client 依赖即可。

思路也很清楚,就是在启动时从服务端把配置信息拉取到本地,然后设置到 Enviroment 中。Spring Cloud Config中有两种形式,一种是指定 url,另外一种是通过服务发现,默认是通过指定URI的方式。这里还是先从客户端的自动配置来分析。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Configuration
@EnableConfigurationProperties
public class ConfigServiceBootstrapConfiguration {

    @Autowired
    private ConfigurableEnvironment environment;
  // 客户端配置属性
    @Bean
    public ConfigClientProperties configClientProperties() {
        ConfigClientProperties client = new ConfigClientProperties(this.environment);
        return client;
    }
  // 从远程服务器上请求对应的配置信息
    @Bean
    @ConditionalOnMissingBean(ConfigServicePropertySourceLocator.class)
    @ConditionalOnProperty(value = "spring.cloud.config.enabled", matchIfMissing = true)
    public ConfigServicePropertySourceLocator configServicePropertySource(ConfigClientProperties properties) {
        ConfigServicePropertySourceLocator locator = new ConfigServicePropertySourceLocator(
                properties);
        return locator;
    }

  // 重试机制
    @ConditionalOnProperty(value = "spring.cloud.config.fail-fast")
    @ConditionalOnClass({ Retryable.class, Aspect.class, AopAutoConfiguration.class })
    @Configuration
    @EnableRetry(proxyTargetClass = true)
    @Import(AopAutoConfiguration.class)
    @EnableConfigurationProperties(RetryProperties.class)
    protected static class RetryConfiguration {

        @Bean
        @ConditionalOnMissingBean(name = "configServerRetryInterceptor")
        public RetryOperationsInterceptor configServerRetryInterceptor(
                RetryProperties properties) {
            return RetryInterceptorBuilder
                    .stateless()
                    .backOffOptions(properties.getInitialInterval(),
                            properties.getMultiplier(), properties.getMaxInterval())
                    .maxAttempts(properties.getMaxAttempts()).build();
        }
    }
}

这个配置类中初始化了两个bean:

  • ConfigClientProperties : 对客户端的属性进行配置。
  • ConfigServicePropertySourceLocator:从远程服务器上请求对应的配置信息,然后注册到容器的Enviroment 对象中去。

ConfigClientProperties 中就是客户端的一些属性,如:profile、应用名、标签、远端服务地址等。没有什么特殊的逻辑。主要来看下 ConfigServicePropertySourceLocator 。

ConfigServicePropertySourceLocator

ConfigServicePropertySourceLocator 实现了 PropertySourceLocator 接口,PropertySourceLocator 接口的作用就是用来定位 PropertySource 的。直接看locate方法的实现(删除了无关代码):

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
    @Override
    @Retryable(interceptor = "configServerRetryInterceptor")
    public PropertySource<?> locate(Environment environment) {
        ConfigClientProperties properties = this.defaultProperties.override(environment);
        CompositePropertySource composite = new CompositePropertySource("configService");
    // 实例化一个 restTemplate,用来调用服务端的 API
        RestTemplate restTemplate = this.restTemplate == null
                ? getSecureRestTemplate(properties)
                : this.restTemplate;
    // ...
        try {
      // labels ,对对应于profile 如,dev,pre,test这些
            String[] labels = new String[] { "" };
            if (StringUtils.hasText(properties.getLabel())) {
                labels = StringUtils.commaDelimitedListToStringArray(properties.getLabel());
            }
            String state = ConfigClientStateHolder.getState();
            // 遍历所有的标签,循环调用获取远程配置信息
            for (String label : labels) {
        // h获取远端环境配置信息
                Environment result = getRemoteEnvironment(restTemplate, properties,
                        label.trim(), state);
                if (result != null) {
                    log(result);
          // result.getPropertySources() can be null if using xml
          //使用 xml,可能会为 null
                    if (result.getPropertySources() != null) { 
                        for (PropertySource source : result.getPropertySources()) {
                            @SuppressWarnings("unchecked")
                            Map<String, Object> map = (Map<String, Object>) source
                                    .getSource();
                            composite.addPropertySource(
                                    new MapPropertySource(source.getName(), map));
                        }
                    }
          // 设置客户端状态和版本号信息
                    if (StringUtils.hasText(result.getState())
                            || StringUtils.hasText(result.getVersion())) {
                        HashMap<String, Object> map = new HashMap<>();
                        putValue(map, "config.client.state", result.getState());
                        putValue(map, "config.client.version", result.getVersion());
                        composite.addFirstPropertySource(
                                new MapPropertySource("configClient", map));
                    }
                    return composite;
                }
            }
        }
        catch (Exception e) {
            // ...
        }
    // 如果设置了fial fast ,失败时抛出异常
        if (properties.isFailFast()) {
            // ...
        }
    // ...
        return null;
    }

上面代码片段中实际从远端获取配置信息是在 getRemoteEnvironment 这个方法中,以Http 请求的方式获取。获取到配置信息之后是放在 CompositePropertySource 对象中,代码较长,逻辑也比较简单,建议直接阅读源码。源于这部分 自定义属性源也有说明。

注入到 Enviroment 中

这部分操作是在 Spring Cloud Context 中的入口来完成的。具体参考 bootstrapServiceContext 创建&启动 。 这里会通过 Spring Cloud Context 中的 PropertySourceBootstrapConfiguration 配置类将PropertySourceLocator 自定义属性值添加到引导上下文的环境当中。

基于服务发现的方式获取配置

前面两个小节均是基于指定 http url 的方式获取配置文件的。Spring Cloud Config 中还有一种方式就是基于服务发现的方式。其实这种方式说到底还是基于指定 http url的方式调用,只是通过服务发现找到服务端地址;当然既然有服务的发现与注册,也就会涉及到客户端与服务端之间的会话保证,及时更新可用服务列表这些功能。

  • 获取服务地址
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Retryable(interceptor = "configServerRetryInterceptor")
    public List<ServiceInstance> getConfigServerInstances(String serviceId) {
        logger.debug("Locating configserver (" + serviceId + ") via discovery");
        List<ServiceInstance> instances = this.client.getInstances(serviceId);
        if (instances.isEmpty()) {
            throw new IllegalStateException(
                    "No instances found of configserver (" + serviceId + ")");
        }
        logger.debug("Located configserver (" + serviceId
                + ") via discovery. No of instances found: " + instances.size());
        return instances;
    }

通过 DiscoveryClient 客户端,以指定serviceId的方式拿到服务地址。

DiscoveryClientConfigServiceBootstrapConfiguration 这个自动配置类实现了 ApplicationListener,用于监听上下文刷新事件;DiscoveryClient 在具体的实现中会将上下文刷新事件进行广播,然后执行刷新操作。心跳里面也是执行的刷新操作。对应的方法是DiscoveryClientConfigServiceBootstrapConfiguration#refresh。也就是 refresh方法会根据上下文环境和心跳事件,刷新服务实例。

以 ZK 作为配置中心

《SpringCloud-配置中心 spring-cloud-zk》demo 中介绍了如何使用 zk 作为配置中心。以zk作为配置中心也就是配置信息将从zk中来获取;具体实现也就是实现 PropertySourceLocator 接口,在locate方法中通过zk客户端从zk服务端拉取配置信息。具体实现在ZookeeperPropertySourceLocator#locate中

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Override
    public PropertySource<?> locate(Environment environment) {
        if (environment instanceof ConfigurableEnvironment) {
      //省略 ...
            // 获取外部配置源
            PropertySource propertySource = create(propertySourceContext);
      //省略 ...
        }
        // ..
    }

其他代码片段都省略了,获取 PropertySource 是在 create 方法中,create 方法返回一个 ZookeeperPropertySource 实例对象。在构造函数中,有通过zk客户端去拉取配置信息,具体逻辑在findProperties 方法中:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
private void findProperties(String path, List<String> children) {
        try {
            // 省略 ... 
            for (String child : children) {
                String childPath = path + "/" + child;
                List<String> childPathChildren = getChildren(childPath);
        // 获取节点信息
                byte[] bytes = getPropertyBytes(childPath);
                if (bytes == null || bytes.length == 0) {
                    if (childPathChildren == null || childPathChildren.isEmpty()) {
                        registerKeyValue(childPath, "");
                    }
                } else {
                    registerKeyValue(childPath, new String(bytes, Charset.forName("UTF-8")));
                }
                // 检查子节点,即使我们已经找到当前znode的值
                findProperties(childPath, childPathChildren);
            }
        } catch (Exception exception) {
            // 省略 ... 
        }
    }

自动刷新机制

当修改配置信息之后,通过zk自身的监听机制,通知客户端。这个机制是在ZookeeperConfigAutoConfiguration自动配置类中提供。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Configuration
    @ConditionalOnClass(RefreshEndpoint.class)
    protected static class ZkRefreshConfiguration {
        @Bean
        @ConditionalOnProperty(name = "spring.cloud.zookeeper.config.watcher.enabled", matchIfMissing = true)
        public ConfigWatcher configWatcher(ZookeeperPropertySourceLocator locator,
                CuratorFramework curator) {
            return new ConfigWatcher(locator.getContexts(), curator);
        }
    }

ConfigWatcher 实现了 Closeable、TreeCacheListener 和 ApplicationEventPublisherAware 三个接口。Tree Cache 用于观察所有节点的所有数据状态,ApplicationEventPublisherAware用户提供一个publiser,用来发布RefreshEvent 事件。Closeable 用于实现优雅关闭。

所有当我们改变zk数据节点时,就是触发例如 NODE_ADDED 、NODE_REMOVED、NODE_UPDATED 等事件类型,然后publiser就会发布一个 RefreshEvent 事件,通知客户端进行配置更新操作。从而实现配置的自动刷新。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2019-01-11,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 磊叔的技术博客 微信公众号,前往查看

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

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

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
SpringCloud分布式配置中心
Spring Cloud Config为服务端和客户端提供了分布式系统的外部化配置支持。配置服务器为各应用的所有环境提供了一个中心化的外部配置。它实现了对服务端和客户端对SpringEnvironment和PropertySource抽象的映射,所以它除了适用于Spring构建的应用程序,也可以在任何其他语言运行的应用程序中使用。作为一个应用可以通过部署管道来进行测试或者投入生产,我们可以分别为这些环境创建配置,并且在需要迁移环境的时候获取对应环境的配置来运行。
程序大视界
2020/07/21
6090
SpringCloud分布式配置中心
springcloud之配置中心git
随着线上项目变的日益庞大,每个项目都散落着各种配置文件,如果采用分布式的开发模式,需要的配置文件随着服务增加而不断增多。某一个基础服务信息变更,都会引起一系列的更新和重启,运维苦不堪言也容易出错。
Vincent-yuan
2020/12/01
5760
springcloud之配置中心git
Spring Cloud(4)——分布式配置中心
Spring Cloud Config是一个配置管理工具包,让你可以把配置放到远程服务器,集中化管理集群配置,目前支持本地存储、Git以及Subversion。 Spring Cloud Config分为两部分
会跳舞的机器人
2018/09/21
4250
Spring Cloud(4)——分布式配置中心
Spring Cloud 覆写远端的配置属性
覆写远端的配置属性 应用的配置源通常都是远端的Config Server服务器,默认情况下,本地的配置优先级低于远端配置仓库。如果想实现本地应用的系统变量和config文件覆盖远端仓库中的属性值,可以通过如下设置: spring: cloud: config: allowOverride: true overrideNone: true overrideSystemProperties: false overrideNone:当allowOverride为t
aoho求索
2018/04/03
1.5K0
Spring Cloud 覆写远端的配置属性
配置中心 - Spring Cloud Config
使用postman通过POST方法访问接口http://localhost:8080/actuator/refresh 注意:Spring Boot 2.x,是/actuator/refresh,而不是/refresh
十毛
2019/03/27
5560
配置中心 - Spring Cloud Config
Spring Cloud(八)高可用的分布式配置中心 Spring Cloud Config
在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件。在Spring Cloud中,有分布式配置中心组件spring cloud config,它支持配置服务放在配置服务的内存中(即本地),也支持放在远程Git仓库中。在spring cloud config 组件中,分两个角色,一是config server,二是config client,业界也有些知名的同类开源产品,比如百度的disconf。 相比较同类产品,SpringCloudConfig最大的优势是
程序员鹏磊
2018/02/09
9430
Spring Cloud(八)高可用的分布式配置中心 Spring Cloud Config
SpringCloud详细教程 | 第七篇:分布式配置中心(Spring Cloud Config) (Greenwich版本)
Spring Cloud Config为分布式系统中的外部化配置提供服务器端和客户端支持。在分布式系统中,由于服务数量很多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件。在Spring Cloud中,有分布式配置中心组件spring cloud config ,它支持配置服务放在配置服务的内存中(即本地),也支持放在远程Git仓库中同时也可以存放在Mysql数据库。在spring cloud config 组件中,分两个角色,一是config server,二是config client
小东啊
2019/06/26
2K0
SpringCloud详细教程 | 第七篇:分布式配置中心(Spring Cloud Config) (Greenwich版本)
SpringCloud集成Config分布式配置中心
微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的服务。由于每个服务都需要必要的配置信息才能运行,所以一套集中式的、动态的配置管理设施是必不可少的。
大忽悠爱学习
2021/12/07
2830
SpringCloud集成Config分布式配置中心
SpringCloud Config分布式配置中心
  微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的服务。由于每个服务都需要必要的配置信息才能运行,所以一套集中式的、动态的配置管理设施是必不可少的。
别团等shy哥发育
2023/02/25
3130
SpringCloud Config分布式配置中心
spring_cloud config 配置中心及利用Github实现自动化热加载配置
    spring_cloud有着强大的生态支持,其自带的分布式配置中心可以有效解决分布式环境中配置不统一的问题,提供一个中心化的配置中心。并且依靠其spring_bus(rabbitMq提供订阅)和github或者gitlab自带的webhook(钩子函数)可以实现将修改好后的配置push到远程git地址后,通过访问配置服务器的endPoints接口地址,便可将配置中心的变化推送到各个集群服务器中。
chinotan
2019/04/03
1.1K0
spring_cloud config 配置中心及利用Github实现自动化热加载配置
Spring Boot + Spring Cloud 构建微服务系统(九):配置中心(Spring Cloud Config)
如今微服务架构盛行,在分布式系统中,项目日益庞大,子项目日益增多,每个项目都散落着各种配置文件,且随着服务的增加而不断增多。此时,往往某一个基础服务信息变更,都会导致一系列服务的更新和重启,运维也是苦不堪言,而且还很容易出错。于是,配置中心便由此应运而生了。
朝雨忆轻尘
2019/06/19
6960
Spring Boot + Spring Cloud 构建微服务系统(九):配置中心(Spring Cloud Config)
SpringCloud-Config配置中心
微服务意味着要将单体应用中的业务拆分成一个个子服务, 每个服务的粒度相对较小,因此系统中会出现大量的服务。由于每个服务都需要必要的配置信息才能运行,所以一套集中式的、动态的配置管理设施是必不可少的。
乐心湖
2020/07/31
9360
SpringCloud-Config配置中心
分布式配置中心Spring Cloud Config初窥
随着我们的分布式项目越来越大,我们可能需要将配置文件抽取出来单独管理,Spring Cloud Config对这种需求提供了支持。Spring Cloud Config为分布式系统中的外部配置提供服务器和客户端支持。我们可以使用Config Server在所有环境中管理应用程序的外部属性,Config Server也称为分布式配置中心,本质上它就是一个独立的微服务应用,用来连接配置仓库并将获取到的配置信息提供给客户端使用;客户端就是我们的各个微服务应用,我们在客户端上指定配置中心的位置,客户端在启动的时候就
江南一点雨
2018/04/02
6040
分布式配置中心Spring Cloud Config初窥
SpringCloud Config分布式配置中心
cheese
2023/10/25
3490
SpringCloud Config分布式配置中心
重学SpringCloud系列四之分布式配置中心---上
为了避免参数变化引起的频繁的程序改动,通常我们在应用程序中将常用的一些系统参数、启动参数、数据库参数等等写到配置文件或其他的存储介质里面。
大忽悠爱学习
2022/05/09
8460
重学SpringCloud系列四之分布式配置中心---上
SpringCloud Config分布式配置中心
微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的服务。由于每个服务都需要必要的配置信息才能运行,所以一套集中式的、动态的配置管理设施是必不可少的。  SpringCloud提供了ConfigServer来解决这个问题,我们每一个微服务自己带着一个application.yml,上百个配置文件的管理......
一个风轻云淡
2022/11/13
3400
SpringCloud Config分布式配置中心
Spring Cloud Config
Spring Cloud Config 为微服务提供了集中化的外部配置支持,配置服务器为不同微服务应用的所有环境提供了一个中心化的外部配置。
灰太狼学Java
2022/06/17
7410
springcloud(六):配置中心git示例
随着线上项目变的日益庞大,每个项目都散落着各种配置文件,如果采用分布式的开发模式,需要的配置文件随着服务增加而不断增多。某一个基础服务信息变更,都会引起一系列的更新和重启,运维苦不堪言也容易出错。配置中心便是解决此类问题的灵丹妙药。 市面上开源的配置中心有很多,BAT每家都出过,360的QConf、淘宝的diamond、百度的disconf都是解决这类问题。国外也有很多开源的配置中心Apache Commons Configuration、owner、cfg4j等等。这些开源的软件以及解决方案都很优秀,但是
纯洁的微笑
2018/04/19
9830
Spring Cloud Config 配置中心实践过程中,你需要了解这些细节!
本文主要介绍 Spring Cloud Config 基本概念、实践过的配置及遇到的问题进行剖析。关于如何启动运行配置中心可以参考官方 Demo。
Bug开发工程师
2019/10/15
1.3K0
Spring Cloud Config 配置中心实践过程中,你需要了解这些细节!
SpringCloud——Config、Bus、Stream
在微服务架构中,构建公用的消息主题并由其他微服务去订阅和消费,从而起到广播通知的作用,那么我们就称之为消息总线。
爪哇缪斯
2023/05/10
1.4K0
SpringCloud——Config、Bus、Stream
相关推荐
SpringCloud分布式配置中心
更多 >
交个朋友
加入腾讯云官网粉丝站
蹲全网底价单品 享第一手活动信息
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档