Spring 配置化
-
Environment抽象 -
PropertySource抽象
Environment抽象
环境信息org.springframework.core.env.Environment
扩展接口
ConfigurableEnvironment可配置的环境信息ConfigurableWebEnvironment可配置的web环境信息
标准实现
StandardEnvironment标准的环境StandardServletEnvironmentServlet环境下的环境
生命周期
创建
org.springframework.context.support.AbstractApplicationContext#prepareRefresh
1 | |
初始化
通过构造器进行初始化,加载方法org.springframework.core.env.AbstractEnvironment#customizePropertySources
初始化的顺序详见
PropertySource抽象
1 | |
完成
PropertySource抽象
Environment对应一个MutablePropertySources,这个一个组合对象,包含多个PropertySource
servletConfigInitParams->StubPropertySourceweb环境加载的时候会替换成
ServletConfigPropertySourceservletContextInitParams->StubPropertySourceweb环境加载的时候会替换成
ServletContextPropertySourcejndiProperties->JndiPropertySourcesystemEnvironment->PropertiesPropertySource(Map) System.getProperties()systemProperties->SystemEnvironmentPropertySource(Map) System.getenv()
Spring 配置化
http://example.com/2019/12/21/Spring/Spring 配置化/