Spring PropertySources 与 PropertySource


org.springframework.core.env.PropertySources 是多个 org.springframework.core.env.PropertySource 的集合,是 spring 管理和保存属性配置的关键接口。
SpringBoot 在启动时,会通过 PropertySourcesPlaceholderConfigurer 装载 PropertySources,往 PropertySources 中放两个对象:environmentProperties 和 localProperties。

environmentProperties 的 environment 配置源中存放着各种 PropertySource,例如:

SystemEnvironmentPropertySource
PropertiesPropertySource
CommandLineProperySource
ResourcePropertySource
ServletContextPropertySource
RandomValuePropertySource
......

 

 

org.springframework.core.env.Environment :Environment 对象的作用是为用户提供一个方便的服务接口,用于配置属性源并从中解析属性。

 

 

Spring 中将配置源抽象成 org.springframework.core.env.PropertySource 对象,PropertySource 是属性配置源的抽象基类

 

 

配置生效顺序

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM