首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    基于SpringBoot的Environment源码理解实现分散配置

    ConfigurableEnvironment:继承自ConfigurablePropertyResolver和Environment,并且提供设置激活的profile和默认的profile的功能。...ConfigurableWebEnvironment:继承自ConfigurableEnvironment,并且提供配置Servlet上下文和Servlet参数的功能。...AbstractEnvironment:实现了ConfigurableEnvironment接口,默认属性和存储容器的定义,并且实现了ConfigurableEnvironment种的方法,并且为子类预留可覆盖了扩展方法...实例 ConfigurableEnvironment environment = getOrCreateEnvironment(); //启动参数绑定到ConfigurableEnvironment...加载完毕之后,ConfigurableEnvironment中基本包含了所有需要加载的属性(activeProfiles是这个时候被写入ConfigurableEnvironment)。

    1.8K20

    SpringBoot源码 | prepareEnvironment方法解析

    SpringApplication对象以及SpringApplication.run方法执行的内容,今天主要细讲的是SpringApplication.run中的准备环境的prepareEnvironment方法源码ConfigurableEnvironment...DefaultBootstrapContext bootstrapContext, ApplicationArguments applicationArguments) { // 创建和配置环境 ConfigurableEnvironment...convertEnvironment(environment); } ConfigurationPropertySources.attach(environment); //返回环境配置对象ConfigurableEnvironment...bindToSpringApplication将环境配置参数绑定到SpringApplication convertEnvironment 如果isCustomEnvironment为false则将ConfigurableEnvironment...application environment并且不直接解析配置文件属性的应用程序环境 最后再执行一次ConfigurationPropertySources.attach,完成之后返回环境配置对象ConfigurableEnvironment

    13210

    Spring加载流程源码分析02【setConfigLocations】

    locations[i]).trim(); } } else { this.configLocations = null; } } setConfigLocations主要工作有两个:创建环境对象ConfigurableEnvironment...、处理ClassPathXmlApplicationContext传入的字符串中的占位符; 环境对象ConfigurableEnvironment中包含了当前JVM的profile配置信息、环境变量、...Java进程变量; 处理占位符的关键是ConfigurableEnvironment、PropertyResolver、PropertyPlaceholderHelper之间的配合 // 这个方法的目的是替换掉.../ 2.进入resolveRequiredPlaceholders方法 return getEnvironment().resolveRequiredPlaceholders(path); } 1.ConfigurableEnvironment...  getEnvironment():创建了ConfigurableEnvironment 对象 public ConfigurableEnvironment getEnvironment() {

    1K30

    Spring Boot启动过程分析

    默认是只读的接口,接口名前面加Configurable对应是一个提供可配置接口的新接口——在Spring很多配置相关的接口中都有这样的继承形式,例如ConfigurableEnvironment和Environment...ConfigurableEnvironment 一般在写业务代码时使用的都是只读类型的接口Environment,该接口是对运行程序环境的抽象,是保存系统配置的中心,而在启动过程中使用的则是可编辑的ConfigurableEnvironment...ConfigurableEnvironment.png EventPublishingRunListener ?...首先Spring会根据web容器的类型新建一个ConfigurableEnvironment,不同的web容器类型的Environment会重载customizePropertySources方法,该方法会注入不同的...listeners, ApplicationArguments applicationArguments) { //新建\获取当前Environment实例 ConfigurableEnvironment

    1.1K20

    扫码

    添加站长 进交流群

    领取专属 10元无门槛券

    手把手带您无忧上云

    扫码加入开发者社群

    相关资讯

    热门标签

    活动推荐

      运营活动

      活动名称
      广告关闭
      领券