zoukankan      html  css  js  c++  java
  • Spring项目启动报"Could not resolve placeholder"解决

    1.问题的起因:

      

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

      比如我有一个dao.xml读取dbConnect.properties,还有一个dfs.xml读取dfsManager.properties,然后web.xml统一load这两个xml文件,就导致该问题的出现。

    解决方法:

      (1)在Spring 3.0中,可以写

    Xml代码 

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

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

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

      虽然两者是的等价的,但估计大家还是喜欢写<context:property-placeholder>多一些,毕竟简单一些嘛。所以如果是Spring 3.0,直接用解决方案(1)再简单不过了;如果是Spring 2.5,需要费点力气改写成PropertyPlaceholderConfigurer

  • 相关阅读:
    SVO深度解析(三)之深度滤波(建图部分)
    SVO深度解析(二)之跟踪部分
    SVO深度解析(一)之简介和评价
    图像三维重建方法综述
    SLAM优化位姿时,误差函数的雅可比矩阵的推导。
    Canny边缘检测原理与C++实现(2)实现部分
    Canny边缘检测原理与C++实现(1)原理部分
    指针的大小是谁决定的
    Ubuntu 16.04配置CUDA 9.0+cudnn 7.0以及解决Nvidia显卡导致黑屏问题
    安装FAB-Map 2.0,Ubtuntu 16.04
  • 原文地址:https://www.cnblogs.com/sunlightlee/p/5750193.html
Copyright © 2011-2022 走看看