properties 如果在 spring 中通过 PropertyPlaceholderConfigurer 加载,当spring 中需要 用到 properties 中的一些 key 和value 值时可以 利用 PorpertyPlaceholderConfiger 提供的$ 直接 取得。
PorpertyPlaceholderConfiger 有一些常用的属性,在一些高级应用中,可能会用到
举例如下:
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:*.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${driverClass}"></property> --->表明 properties文件中有 driverClass = aaa,通过${driverClass} 就能拿到 aaa值了
<property name="jdbcUrl" value="${url}"></property>
Spring 中 用 ${xxx} 读取properties文件的说明
原文:http://www.cnblogs.com/wzhanke/p/4839004.html