首页 > 编程语言 > 详细

Spring context:property-placeholder 一些坑

时间:2017-06-14 20:52:12      阅读:343      评论:0      收藏:0      [点我收藏+]

今天在配置多配置文件的时候偶然发现如果我使用

 1 <context:property-placeholder location="classpath:filePath.properties"/> 
这个进行多行编写配置文件的时候会出现后面那个文件出现读取不到的问题

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

这样会导致后面那个配置文件失效

原因:Spring 只会加载第一个context:property-placeholder配置后面的文件将不会再次进行加载,所以导致后面的文件读取不到

解决办法:

    <context:property-placeholder ignore-unresolvable="true" location="classpath:jdbc.properties,classpath:filePath.properties"/>

加入一个ignore-unresolvable="true"属性,将文件用,隔开就可以了

  

Spring context:property-placeholder 一些坑

原文:http://www.cnblogs.com/lonecloud/p/7010651.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!