1.local属性
引用在同一个xml的bean 只能引用bean的id
<bean id="HelloWord" class="com.ltf.captha.serviceImpl.HelloWorld" destroy-method="destory"> <property name="date"> <ref local="date"/> </property> </bean> <bean id="date" class="java.util.Date"></bean>
2.bean属性
引用在同一个xml的bean,或者不在同一个xml的bean bean还可以引用bean的name
<bean id="HelloWord" class="com.ltf.captha.serviceImpl.HelloWorld" destroy-method="destory"> <property name="date"> <ref bean="date"/> </property> </bean> <bean id="date" class="java.util.Date"></bean
3.parent属性
<bean id="inheritedTestBeanWithoutClass"> <property name="name"><value>parent</value></property> <property name="age"><value>1</value></property> </bean> <bean id="inheritsWithClass" class="org.springframework.beans.DerivedTestBean" parent="inheritedTestBeanWithoutClass" init-method="initialize"> <property name="name"><value>override</value></property> <!-- age should inherit value of 1 from parent --> </bean>
时间: 2024-10-06 20:50:59