<!--读取单个properties配置文件 -->
<context:property-placeholder location="classpath:com/bc/hawkeye/config/mysql_mongodb.properties"/>
<!-- 连接池 --><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driver}" />
<property name="jdbcUrl" value="${url}" />
<property name="user" value="${username}" />
<property name="password" value="${password}" />
</bean>
(1)使用以下方式读取单个本地文件到xml中:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>file:/opt/config/config1.properties</value> </property> </bean>
(2)使用以下方式读取多个本地文件到xml中:
<!-- 使用spring提供的PropertyPlaceholderConfigurer读取properties -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <!-- 属性名是 locations,使用子标签<list></list>可以指定多个数据库的配置文件,这里指定了一个-->
<property name="locations"> <list> <value>file:/opt/config/config1.properties</value>
<value>file:/opt/config/config2.properties</value> </list> </property> <property name="ignoreUnresolvablePlaceholders" value="true"/> </bean>