原文地址:http://blog.sina.com.cn/s/blog_a0de59cf0101dqeb.html

spring去加载,这个元素的写法如下:

<context:property-placeholder location="classpath:jdbc.properties"/>

如果想要配置多个properties文件

<context:property-placeholder location="classpath:jdbc.properties"/>

<context:property-placeholder location="classpath:jdbc.properties"/>

这种方式是不被允许的,一定会出"Could not resolve placeholder"

解决方案:

(1) Spring 3.0中,可以写:

<context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/>

<context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/>

(2) 但是Spring 2.5中,没有ignore-unresolvable属性,所以就不能使用上面的那种方法去配置,

可以改如下的格式:

<bean id="propertyConfigurer"

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="locations">

<list>

<value>classpath:/jdbc.properties</value>

</list>

</property>

</bean>

posted on 2017-09-05 03:06  Sharpest  阅读(377)  评论(0编辑  收藏  举报