1.首先我们先看WETA-INF下面的配置,spring.factories

nacos-config源码解析

2.应用启动会先加载NacosConfigBootstrapConfiguration类,初始化NacosConfigProperties、NacosConfigManager、NacosPropertySourceLocator,初始化完NacosPropertySourceLocator会执行locate方法,

nacos-config源码解析

3.loadSharedConfiguration、loadExtConfiguration、loadApplicationConfiguration都通过loadNacosDataIfPresent去调用NacosPropertySourceBuilder中build通过configService.getConfig获取到远程配置。

nacos-config源码解析

4.通过NacosPropertySourceBuilder中build中的configService.getConfig(dataId, group, timeout);去获取nacos中的配置,

nacos的连接是通过nacos-api中的NacosFactory.createConfigService()去创建nacos的连接。

5.yml的配置转化成Map的解析:

nacos-config源码解析

相关文章: