当applicationContext.xml,item-servlet.xml,jdbc.properties是放在WEB-INF目录下时,配置如下即可 【
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/jdbc.properties</value>
</list>
</property>
</bean>
当放在src目录下时 配置需要如下编写【<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:source/jdbc/jdbc.properties</value>
</list>
</property>
</bean>】
如果 放在src下配置写成<value>source/jdbc/jdbc.properties</value>则会报如下错误:
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is Java.io.FileNotFoundException: Could not open ServletContext resource [/source/jdbc/jdbc.properties]