类 PropertiesConfigurationFactory<T>
- java.lang.Object
- org.springframework.boot.bind.PropertiesConfigurationFactory<T>
- 类型参数:
T
- the target type
- 所有已实现的接口:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.FactoryBean<T>
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.MessageSourceAware
public class PropertiesConfigurationFactory<T> extends Object implements org.springframework.beans.factory.FactoryBean<T>, org.springframework.context.MessageSourceAware, org.springframework.beans.factory.InitializingBean
Validate someProperties
(or optionallyPropertySources
) by binding them to an object of a specified type and then optionally running aValidator
over it.
构造器概要
构造器 构造器 说明 PropertiesConfigurationFactory(Class<?> type)
Create a newPropertiesConfigurationFactory
instance.PropertiesConfigurationFactory(T target)
Create a newPropertiesConfigurationFactory
instance.
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
void
bindPropertiesToTarget()
protected void
customizeBinder(org.springframework.validation.DataBinder dataBinder)
Customize the data binder.T
getObject()
Class<?>
getObjectType()
boolean
isSingleton()
void
setConversionService(org.springframework.core.convert.ConversionService conversionService)
Set the conversion service.void
setExceptionIfInvalid(boolean exceptionIfInvalid)
已过时。as of 1.5, do not specify aValidator
if validation should not occurvoid
setIgnoreInvalidFields(boolean ignoreInvalidFields)
Set whether to ignore invalid fields, that is, whether to ignore bind parameters that have corresponding fields in the target object which are not accessible (for example because of null values in the nested path).void
setIgnoreNestedProperties(boolean ignoreNestedProperties)
Flag to disable binding of nested properties (i.e. those with period separators in their paths).void
setIgnoreUnknownFields(boolean ignoreUnknownFields)
Set whether to ignore unknown fields, that is, whether to ignore bind parameters that do not have corresponding fields in the target object.void
setMessageSource(org.springframework.context.MessageSource messageSource)
Set the message source.void
setPropertySources(org.springframework.core.env.PropertySources propertySources)
Set the property sources.void
setResolvePlaceholders(boolean resolvePlaceholders)
Flag to indicate that placeholders should be replaced during binding.void
setTargetName(String targetName)
Set the target name.void
setValidator(org.springframework.validation.Validator validator)
Set the validator.
构造器详细资料
PropertiesConfigurationFactory
public PropertiesConfigurationFactory(T target)
Create a newPropertiesConfigurationFactory
instance.- 参数:
target
- the target object to bind too- 另请参阅:
PropertiesConfigurationFactory(Class)
PropertiesConfigurationFactory
public PropertiesConfigurationFactory(Class<?> type)
Create a newPropertiesConfigurationFactory
instance.- 参数:
type
- the target type- 另请参阅:
PropertiesConfigurationFactory(Class)
方法详细资料
setIgnoreNestedProperties
public void setIgnoreNestedProperties(boolean ignoreNestedProperties)
Flag to disable binding of nested properties (i.e. those with period separators in their paths). Can be useful to disable this if the name prefix is empty and you don't want to ignore unknown fields.- 参数:
ignoreNestedProperties
- the flag to set (default false)
setIgnoreUnknownFields
public void setIgnoreUnknownFields(boolean ignoreUnknownFields)
Set whether to ignore unknown fields, that is, whether to ignore bind parameters that do not have corresponding fields in the target object.Default is "true". Turn this off to enforce that all bind parameters must have a matching field in the target object.
- 参数:
ignoreUnknownFields
- if unknown fields should be ignored
setIgnoreInvalidFields
public void setIgnoreInvalidFields(boolean ignoreInvalidFields)
Set whether to ignore invalid fields, that is, whether to ignore bind parameters that have corresponding fields in the target object which are not accessible (for example because of null values in the nested path).Default is "false". Turn this on to ignore bind parameters for nested objects in non-existing parts of the target object graph.
- 参数:
ignoreInvalidFields
- if invalid fields should be ignored
setTargetName
public void setTargetName(String targetName)
Set the target name.- 参数:
targetName
- the target name
setMessageSource
public void setMessageSource(org.springframework.context.MessageSource messageSource)
Set the message source.- 指定者:
setMessageSource
在接口中org.springframework.context.MessageSourceAware
- 参数:
messageSource
- the message source
setPropertySources
public void setPropertySources(org.springframework.core.env.PropertySources propertySources)
Set the property sources.- 参数:
propertySources
- the property sources
setConversionService
public void setConversionService(org.springframework.core.convert.ConversionService conversionService)
Set the conversion service.- 参数:
conversionService
- the conversion service
setValidator
public void setValidator(org.springframework.validation.Validator validator)
Set the validator.- 参数:
validator
- the validator
setExceptionIfInvalid
@Deprecated public void setExceptionIfInvalid(boolean exceptionIfInvalid)
已过时。as of 1.5, do not specify aValidator
if validation should not occurSet a flag to indicate that an exception should be raised if a Validator is available and validation fails.- 参数:
exceptionIfInvalid
- the flag to set
setResolvePlaceholders
public void setResolvePlaceholders(boolean resolvePlaceholders)
Flag to indicate that placeholders should be replaced during binding. Default is true.- 参数:
resolvePlaceholders
- flag value
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- 指定者:
afterPropertiesSet
在接口中org.springframework.beans.factory.InitializingBean
- 抛出:
Exception
getObjectType
public Class<?> getObjectType()
- 指定者:
getObjectType
在接口中org.springframework.beans.factory.FactoryBean<T>
isSingleton
public boolean isSingleton()
- 指定者:
isSingleton
在接口中org.springframework.beans.factory.FactoryBean<T>
bindPropertiesToTarget
public void bindPropertiesToTarget() throws org.springframework.validation.BindException
- 抛出:
org.springframework.validation.BindException
customizeBinder
protected void customizeBinder(org.springframework.validation.DataBinder dataBinder)
Customize the data binder.- 参数:
dataBinder
- the data binder that will be used to bind and validate