且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法在Spring XML中指定默认属性值?

更新时间:2022-06-19 23:42:57

您是否正在寻找此处记录的PropertyOverrideConfigurer

Are you looking for the PropertyOverrideConfigurer documented here

http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-factory -overrideconfigurer


PropertyOverrideConfigurer,
另一个bean工厂后处理器,
类似于
PropertyPlaceholderConfigurer,但在
中与后者形成对比,原始的
定义可以具有默认值,或者
根本没有值用于bean属性。
如果重写的属性文件确实
没有某个bean
属性的条目,则使用默认的上下文
定义。

The PropertyOverrideConfigurer, another bean factory post-processor, is similar to the PropertyPlaceholderConfigurer, but in contrast to the latter, the original definitions can have default values or no values at all for bean properties. If an overriding Properties file does not have an entry for a certain bean property, the default context definition is used.