单个.properties,location:
<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
<?xml version="1.0" encoding="UTF-8"?> <!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>
<value>/WEB-INF/classes/log4database.properties</value> </list> </property>
</bean> <bean id="helloBean" class="onlyfun.caterpillar.HelloBean"> <property name="helloWord"> <value>${onlyfun.caterpillar.helloWord}</value> </property> ... </bean> </beans>