一、通过PropertyPlaceholderConfigurer
<!-- 配置数据库连接文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
二、通过spring自定义标签
<context:property-placeholder location="classpath*:jdbc.properties" ignore-unresolvable="true" />
三、注意事项
1、第一种方式通过list加载多个配置文件,第二种方式如果需要加载多个配置文件需要加ignore-unresolvable="true"属性
2、在一个项目中第一种和第二种配置方法不能够混合使用,会产生spring 配置文件读取不到想关上属性的错误。