一、Spring简化了加载资源文件的配置spring
经过<context:property-placeholder去加载,这个元素的写法以下:spa
<context:property-placeholder location="classpath:jdbc.properties"/>
若是想要配置多个properties文件code
<context:property-placeholder location="classpath:jdbc.properties"/> <context:property-placeholder location="classpath:jdbc.properties"/>
这种方式是不被容许的,必定会出"Could not resolve placeholder"。orm
解决之道:xml
(1) 在Spring 3.0中,能够写:ip
<context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/> <context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/>
(2) 可是在Spring 2.5中,<context:property-placeholder>没有ignore-unresolvable属性,因此就不能使用上面的那种方法去配置,资源
能够改以下的格式:it
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/jdbc.properties</value> </list> </property> </bean>