Spring简化了加载资源文件的配置,可以通过<context:property-placeholder去加载,这个元素的写法如下:

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

如果想要配置多个properties文件

<context:property-placeholder location="classpath:jdbc1.properties"/>
<context:property-placeholder location="classpath:jdbc2.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中,<context:property-placeholder>没有ignore-unresolvable属性,所以就不能使用上面的那种方法去配置,可以改如下的格式:

  <bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:/jdbc.properties</value>
            </list>
        </property>
    </bean>

最新文章

  1. SDWebImage源码解读 之 NSData+ImageContentType
  2. css3中变形函数(同样是对元素来说的)和元素通过改变自身属性达到动画效果
  3. CSS实现垂直居中的5种方法
  4. Bootstrap页面布局10 - BS代码
  5. 升级或安装 GNOME Shell
  6. S2sh整合MAven项目所需坐标大全
  7. c/c++面试总结(1)
  8. BZOJ1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛
  9. jQuery ajax 传递数组到struts2
  10. 自定义控件出现“loaded nib but the view outlet was not set”
  11. blur事件
  12. Linux下部署
  13. selenium模拟浏览器对搜狗微信文章进行爬取
  14. 【转载】 mybatis入门系列四之动态SQL
  15. BUAAOO P1-P3 Expression Dirivation
  16. Unity网格合并_材质合并
  17. Java如何检查日期格式是否正确?
  18. leetcode第三题
  19. Codeforces 977F - Consecutive Subsequence - [map优化DP]
  20. python基础(9)-迭代器&amp;生成器函数&amp;生成器进阶&amp;推导式

热门文章

  1. Velocity China 2016 Web 性能与运维大会:构建快速、可扩展的弹性网站
  2. JS+CSS简单实现DIV遮罩层显示隐藏
  3. Asp.NET路由管道处理过程 【重要】
  4. osg蝴蝶纹理
  5. iOS动画编程
  6. RPM安装gcc gcc-c++扩展
  7. APP测试--测试日报和上线报告
  8. socket通信实例
  9. boost log库
  10. Apache+Tomcat服务器集群配置