public abstract class EnvironmentUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
AREA_KEY |
static String |
DEFAULT_PROPERTY_SOURCE_NAME |
static String |
DEFAULT_STANDARD_ENV_KEY |
static String |
ENV_KEY |
static String |
PRODUCT_KEY |
static String |
PROJECT_KEY |
static String |
STANDARD_ENV_KEY |
static String |
STANDARD_ENV_LIST_KEY |
| 构造器和说明 |
|---|
EnvironmentUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addLastButBeforeDefault(org.springframework.core.env.PropertySource<?> propertySource,
org.springframework.core.env.ConfigurableEnvironment environment)
将配置源添加到最后位置,但比`defaultProperties`配置源要前面
|
static void |
addOrMergeDefaultProperties(Map<String,Object> source,
org.springframework.core.env.ConfigurableEnvironment environment)
添加或合并默认配置
|
static void |
addOrMergeDefaultProperties(Map<String,Object> source,
org.springframework.core.env.MutablePropertySources allSources)
添加或合并默认配置
|
static org.springframework.core.env.PropertySource<?> |
addPropertySourceToLast(org.springframework.core.io.Resource configFileResource,
boolean immutable,
org.springframework.core.env.ConfigurableEnvironment environment)
加载配置文件到环境中的最后位置
|
static org.springframework.core.env.PropertySource<?> |
addPropertySourceToLast(String configFilePath,
boolean immutable,
org.springframework.core.env.ConfigurableEnvironment environment)
加载配置文件到环境中的最后位置
|
static Properties |
buildProperties(org.springframework.core.io.Resource configFileResource)
加载配置文件,并创建配置集合
|
static Properties |
buildProperties(String configFilePath)
加载配置文件,并创建配置集合
|
static org.springframework.core.env.MapPropertySource |
buildPropertySource(org.springframework.core.io.Resource configFileResource,
boolean immutable)
创建配置文件为配置源
|
static org.springframework.core.env.MapPropertySource |
buildPropertySource(String configFilePath,
boolean immutable)
创建配置文件为配置源
|
static String |
buildPropertySourceNameByPath(org.springframework.core.io.Resource configFileResource)
根据配置文件路径,创建配置源名称
|
static String |
buildPropertySourceNameByPath(String configFilePath)
根据配置文件路径,创建配置源名称
|
static List<String> |
convertToList(String property)
将单个配置转换为列表(用逗号分隔)
|
static String |
convertToStandard(List<String> standardEnvList,
String env,
String defaultStandardEnv)
转换为标准环境代码
|
static String |
getEnv(org.springframework.core.env.ConfigurableEnvironment environment)
获取环境代码
|
static List<String> |
getPropertyList(org.springframework.core.env.ConfigurableEnvironment environment,
String propertyName)
获取配置列表
|
static List<String> |
getPropertyList(org.springframework.core.env.PropertySource<?> propertySource,
String propertyName)
获取配置列表
|
static org.springframework.core.env.MapPropertySource |
newMapPropertySource(String propertySourceName,
Map<String,Object> source,
boolean immutable)
创建配置源
|
public static void addOrMergeDefaultProperties(@Nullable
Map<String,Object> source,
@NonNull
org.springframework.core.env.MutablePropertySources allSources)
source - 需添加的默认配置allSources - 所有配置源public static void addOrMergeDefaultProperties(@Nullable
Map<String,Object> source,
org.springframework.core.env.ConfigurableEnvironment environment)
source - 需添加的默认配置environment - 环境实例@Nullable public static Properties buildProperties(@NonNull org.springframework.core.io.Resource configFileResource)
configFileResource - 配置文件资源@Nullable public static Properties buildProperties(@NonNull String configFilePath)
configFilePath - 配置文件路径@NonNull public static String buildPropertySourceNameByPath(@NonNull String configFilePath)
configFilePath - 配置文件路径@NonNull public static String buildPropertySourceNameByPath(@NonNull org.springframework.core.io.Resource configFileResource)
configFileResource - 配置文件资源@Nullable
public static org.springframework.core.env.MapPropertySource buildPropertySource(@NonNull
org.springframework.core.io.Resource configFileResource,
boolean immutable)
configFileResource - 配置文件资源immutable - 配置源是否不会更改@NonNull
public static org.springframework.core.env.MapPropertySource newMapPropertySource(@NonNull
String propertySourceName,
@NonNull
Map<String,Object> source,
boolean immutable)
propertySourceName - 配置源名称source - 配置源immutable - 配置源是否不会更改@Nullable
public static org.springframework.core.env.MapPropertySource buildPropertySource(@NonNull
String configFilePath,
boolean immutable)
configFilePath - 配置文件路径immutable - 配置源是否不会更改@Nullable
public static org.springframework.core.env.PropertySource<?> addPropertySourceToLast(@NonNull
org.springframework.core.io.Resource configFileResource,
boolean immutable,
@NonNull
org.springframework.core.env.ConfigurableEnvironment environment)
configFileResource - 配置文件资源immutable - 配置源是否不会更改environment - 环境实例@Nullable
public static org.springframework.core.env.PropertySource<?> addPropertySourceToLast(@NonNull
String configFilePath,
boolean immutable,
@NonNull
org.springframework.core.env.ConfigurableEnvironment environment)
configFilePath - 配置文件路径immutable - 配置源是否不会更改environment - 环境实例public static void addLastButBeforeDefault(@NonNull
org.springframework.core.env.PropertySource<?> propertySource,
@NonNull
org.springframework.core.env.ConfigurableEnvironment environment)
propertySource - 配置源environment - 环境实例@Nullable public static String getEnv(@NonNull org.springframework.core.env.ConfigurableEnvironment environment)
environment - 环境public static String convertToStandard(List<String> standardEnvList, String env, String defaultStandardEnv)
standardEnvList - 标准环境代码数组env - 环境代码defaultStandardEnv - 默认的标准环境代码(如果在数组中没有匹配到,则返回该标准代码)public static List<String> convertToList(String property)
property - 配置值@NonNull public static List<String> getPropertyList(@NonNull org.springframework.core.env.ConfigurableEnvironment environment, String propertyName)
environment - 环境propertyName - 配置名Copyright © 2021–2025 EasyJ寮�婧愮ぞ鍖�. All rights reserved.