• 以 nacos-spring-boot 看 spring-boot


    spring boot 的一个特点是,在 application.properties / yml 中配置后,配置项就会被解析,甚至创建 bean。

    还有一个特点是,通过 starter 管理了依赖项的版本。

    入口在 nacos-config-spring-boot-autoconfigure/META-INF/spring.factories

    org.springframework.boot.autoconfigure.EnableAutoConfiguration=
      com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration
    org.springframework.boot.env.EnvironmentPostProcessor=
      com.alibaba.boot.nacos.config.autoconfigure.NacosConfigEnvironmentProcessor

    自动解析配置,以及自动注册 bean 的逻辑

    @ConditionalOnProperty(name = NacosConfigConstants.ENABLED, matchIfMissing = true)
    @ConditionalOnMissingBean(name = CONFIG_GLOBAL_NACOS_PROPERTIES_BEAN_NAME)
    @EnableConfigurationProperties(value = NacosConfigProperties.class)
    @ConditionalOnClass(name = "org.springframework.boot.context.properties.bind.Binder")
    @Import(value = { NacosConfigBootBeanDefinitionRegistrar.class })
    @EnableNacosConfig
    public class NacosConfigAutoConfiguration {
    
    }

    拉取 nacos 远程配置的逻辑

    com.alibaba.boot.nacos.config.autoconfigure.NacosConfigEnvironmentProcessor
  • 相关阅读:
    求一个字符串中连续出现次数最多的子串
    LintCode: Longest Common Substring
    LintCode: O(1) Check Power of 2
    LintCode: Fizz Buzz
    LintCode: 3 Sum
    LintCode: Two Sum
    LintCode: Sort Colors
    LintCode: Median of two Sorted Arrays
    LintCode: Search A 2d Matrix
    Lintcode: Sqrt(X)
  • 原文地址:https://www.cnblogs.com/allenwas3/p/12492723.html
Copyright © 2020-2023  润新知