接口 ConfigurablePropertyResolver
- 所有超级接口:
PropertyResolver
- 所有已知实现类:
AbstractEnvironment
,AbstractPropertyResolver
,MockEnvironment
,PropertySourcesPropertyResolver
,StandardEnvironment
,StandardPortletEnvironment
,StandardServletEnvironment
public interface ConfigurablePropertyResolver extends PropertyResolver
Configuration interface to be implemented by most if not allPropertyResolver
types. Provides facilities for accessing and customizing theConversionService
used when converting property values from one type to another.- 从以下版本开始:
- 3.1
- 作者:
- Chris Beams
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 ConfigurableConversionService
getConversionService()
Return theConfigurableConversionService
used when performing type conversions on properties.void
setConversionService(ConfigurableConversionService conversionService)
Set theConfigurableConversionService
to be used when performing type conversions on properties.void
setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders)
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property.void
setPlaceholderPrefix(String placeholderPrefix)
Set the prefix that placeholders replaced by this resolver must begin with.void
setPlaceholderSuffix(String placeholderSuffix)
Set the suffix that placeholders replaced by this resolver must end with.void
setRequiredProperties(String... requiredProperties)
Specify which properties must be present, to be verified byvalidateRequiredProperties()
.void
setValueSeparator(String valueSeparator)
Specify the separating character between the placeholders replaced by this resolver and their associated default value, ornull
if no such special character should be processed as a value separator.void
validateRequiredProperties()
Validate that each of the properties specified bysetRequiredProperties(java.lang.String...)
is present and resolves to a non-null
value.从接口继承的方法 org.springframework.core.env.PropertyResolver
containsProperty, getProperty, getProperty, getProperty, getProperty, getPropertyAsClass, getRequiredProperty, getRequiredProperty, resolvePlaceholders, resolveRequiredPlaceholders
方法详细资料
getConversionService
ConfigurableConversionService getConversionService()
Return theConfigurableConversionService
used when performing type conversions on properties.The configurable nature of the returned conversion service allows for the convenient addition and removal of individual
Converter
instances:ConfigurableConversionService cs = env.getConversionService(); cs.addConverter(new FooConverter());
setConversionService
void setConversionService(ConfigurableConversionService conversionService)
Set theConfigurableConversionService
to be used when performing type conversions on properties.Note: as an alternative to fully replacing the
ConversionService
, consider adding or removing individualConverter
instances by drilling intogetConversionService()
and calling methods such as#addConverter
.
setPlaceholderPrefix
void setPlaceholderPrefix(String placeholderPrefix)
Set the prefix that placeholders replaced by this resolver must begin with.
setPlaceholderSuffix
void setPlaceholderSuffix(String placeholderSuffix)
Set the suffix that placeholders replaced by this resolver must end with.
setValueSeparator
void setValueSeparator(String valueSeparator)
Specify the separating character between the placeholders replaced by this resolver and their associated default value, ornull
if no such special character should be processed as a value separator.
setIgnoreUnresolvableNestedPlaceholders
void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders)
Set whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. Afalse
value indicates strict resolution, i.e. that an exception will be thrown. Atrue
value indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form.Implementations of
PropertyResolver.getProperty(String)
and its variants must inspect the value set here to determine correct behavior when property values contain unresolvable placeholders.- 从以下版本开始:
- 3.2
setRequiredProperties
void setRequiredProperties(String... requiredProperties)
Specify which properties must be present, to be verified byvalidateRequiredProperties()
.
validateRequiredProperties
void validateRequiredProperties() throws MissingRequiredPropertiesException
Validate that each of the properties specified bysetRequiredProperties(java.lang.String...)
is present and resolves to a non-null
value.- 抛出:
MissingRequiredPropertiesException
- if any of the required properties are not resolvable.