PropertyPlaceholderConfigurer supports "${myKey:myDefaultValue}" defaulting syntax
This commit is contained in:
@@ -99,6 +99,9 @@ public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
/** Default placeholder suffix: "}" */
|
||||
public static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";
|
||||
|
||||
/** Default value separator: ":" */
|
||||
public static final String DEFAULT_VALUE_SEPARATOR = ":";
|
||||
|
||||
|
||||
/** Never check system properties. */
|
||||
public static final int SYSTEM_PROPERTIES_MODE_NEVER = 0;
|
||||
@@ -122,6 +125,8 @@ public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
|
||||
private String placeholderSuffix = DEFAULT_PLACEHOLDER_SUFFIX;
|
||||
|
||||
private String valueSeparator = DEFAULT_VALUE_SEPARATOR;
|
||||
|
||||
private int systemPropertiesMode = SYSTEM_PROPERTIES_MODE_FALLBACK;
|
||||
|
||||
private boolean searchSystemEnvironment = true;
|
||||
@@ -360,7 +365,8 @@ public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
private final PlaceholderResolver resolver;
|
||||
|
||||
public PlaceholderResolvingStringValueResolver(Properties props) {
|
||||
this.helper = new PropertyPlaceholderHelper(placeholderPrefix, placeholderSuffix, ignoreUnresolvablePlaceholders);
|
||||
this.helper = new PropertyPlaceholderHelper(
|
||||
placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders);
|
||||
this.resolver = new PropertyPlaceholderConfigurerResolver(props);
|
||||
}
|
||||
|
||||
@@ -370,6 +376,7 @@ public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
|
||||
|
||||
private final Properties props;
|
||||
|
||||
Reference in New Issue
Block a user