是否可以在spring上下文文件中定义,以及可以在<bean>元素中访问的一个或多个属性.
下面的例子说明了我最需要的东西 - 我想要定义属性FOO一次,然后在我的各种<bean>定义中多次引用它:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<properties>
<property name="FOO" value="BAR">
</properties>
<bean name="TEST" class="mytest">
<property name="MYFOO" value="${FOO}"/>
</bean>
<bean name="TEST1" class="mytest1">
<property name="MYFOO" value="${FOO}"/>
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
任何输入都将非常感激.
谢谢,凯文.
| 归档时间: |
|
| 查看次数: |
17735 次 |
| 最近记录: |