<bean id="configBean"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>hello.properties</value>
</property>
</bean>
引用:
<property name="list">
<list>
<value>aaa</value>
<value>${name}</value>
<ref bean="date" />
</list>
</property>
-----------------------------------------------------------------
如果有多个.properties档案,则可以透过locations属性来设定,例如:
- beans-config.xml
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="configBean"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>hello.properties</value>
<value>welcome.properties</value>
<value>other.properties</value>
</list>
</property>
</bean>
<bean id="helloBean" class="onlyfun.caterpillar.HelloBean">
<property name="helloWord">
<value> ${onlyfun.caterpillar.helloWord} </value>
</property>
...
</bean>
</beans>