您的位置:首页 > 移动开发

spring applicationContext.xml配置

2016-05-06 09:25 519 查看
当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]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: