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。。

相關文章
相關標籤/搜索