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 是屬性配置源的抽象基類
配置生效順序