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