Spring报Could not resolve placeholder解决法

 时间:2026-02-13 14:43:17

1、比如我有一个dao.xml读取dbConnect.properties,还有一个dfs.xml读取dfsManager.properties,然后web.xml统一load这两个xml文件

Spring报Could not resolve placeholder解决法

2、如果这两个xml文件中分别有

<!-- dao.xml -->  

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

  

<!-- dfs.xml -->  

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

那么,一定会出"Could not resolve placeholder"。

Spring报Could not resolve placeholder解决法

3、一定要记住,不管是在一个spring文件还是在多个Spring文件被统一load的情况下,直接写

<context:property-placeholder location="" />  

<context:property-placeholder location="" />   

是不允许的。

Spring报Could not resolve placeholder解决法

4、解决方案:

  (1) 在Spring 3.0中,可以写:

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

/>  

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

/>

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

Spring报Could not resolve placeholder解决法

5、(2) 在Spring 2.5中,<context:property-placeholder>没有ignore-unresolvable属性,此时可以改用PropertyPlaceholderConfigurer。其实<context:property-placeholder location="xxx.properties" ignore-unresolvable="true" />与下面的配置是等价的。

<bean id="随便" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  

    <property name="location" value="xxx.properties" />  

    <property name="ignoreUnresolvablePlaceholders" value="true" />   

</bean>  

正因为如此,写多个PropertyPlaceholderConfigurer不加ignoreUnresolvablePlaceholders属性也是一样会出"Could not resolve placeholder"。

Spring报Could not resolve placeholder解决法

  • 钉钉消息怎么设置待办
  • 07版excel如何锁定固定某些单元格不被编辑
  • excel表格,下拉选项如何修改
  • EXCEL中设置有下拉框的选择功能怎么做
  • Excel使用技巧之如何自动隐藏乱码
  • 热门搜索
    阳痿怎么治 鸽子怎么杀 万用表怎么用 zoom怎么读 艾滋病怎么检查 电工证怎么考 固特异轮胎怎么样 得了甲状腺结节怎么办 怎么潮吹 手脚冰凉怎么办