<bean id="parent" abstract="true" class="......">
<property name="someProperties">
<props>
<prop key="someKey1">someProValue1</prop>
<prop key="someKey2">someProValue2</prop>
</props>
</property>
</bean>
<bean id="child" parent="parent" class="......">
<property name="someProperties">
<props merge="true">
<prop key="someKey2">anotherProValue2</prop>
<prop key="someKey3">someProValue3</prop>
</props>
</property>
</bean>最后,child这个bean的peoperties属性值如下:
someKey1=someProValue
someKey2=anotherProValue2
someKey3=anotherProValue3
本文探讨了Spring框架中Bean的定义方式,特别是在父Bean的基础上通过子Bean进行属性覆盖及扩展的方法。具体展示了如何利用XML配置文件实现Bean的继承与属性的合并。
1452

被折叠的 条评论
为什么被折叠?



