Spring中报"Could not resolve placeholder"的解决方案

除去properites文件路径错误、拼写错误外,出现"Could not resolve placeholder"颇有多是使用了多个PropertyPlaceholderConfigurer或者多个<context:property-placeholder>的缘由。web

好比我有一个dao.xml读取dbConnect.properties,还有一个dfs.xml读取dfsManager.properties,而后web.xml统一load这两个xml文件spring

若是这两个xml文件中分别有xml

<!-- dao.xml -->  it

<context:property-placeholder location="WEB-INF/config/db/dbConnect.properties" />   io

<!-- dfs.xml -->  db

<context:property-placeholder location="WEB-INF/config/dfs/dfsManager.properties" />文件

那么,必定会出"Could not resolve placeholder"。解决方案

 

解决方案:co

  在Spring 3.0中,能够写:dao

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

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

注意两个都要加上ignore-unresolvable="true",一个加另外一个不加也是不行的

spring3.0如下版本应用太少,自行Google。。

相关文章
相关标签/搜索