问题的起因:

  除去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

【转】Spring项目启动报"Could not resolve placeholder"解决方法的更多相关文章

  1. Spring项目启动报"Could not resolve placeholder"解决

    1.问题的起因: 除去properites文件路径错误.拼写错误外,出现"Could not resolve placeholder"很有可能是使用了多个PropertyPlace ...

  2. spring项目启动报错BeanFactory not initialized or already closed

    spring项目启动的时候报如下错误: java.lang.IllegalStateException: BeanFactory not initialized or already closed - ...

  3. 启动web项目,报内存不足错误的解决方法

    Initialization of bean failed; nested exception is java.lang.OutOfMemoryError: Java heap space 原因: 在 ...

  4. spring项目启动报错

    个人博客 地址:http://www.wenhaofan.com/article/20180921134534 错误信息 ERROR [localhost-startStop-1] - Context ...

  5. 【spring cloud】【spring boot】项目启动报错:Cannot determine embedded database driver class for database type NONE

    解决参考文章:https://blog.csdn.net/hengyunabc/article/details/78762097 spring boot启动报错如下: Error starting A ...

  6. maven项目启动报错;class path resource [com/ssm/mapping/] cannot be resolved to URL because it does not exist

    项目启动报了一堆错误,其实都是class path resource [com/ssm/mapping/] cannot be resolved to URL because it does not ...

  7. Linux下Tomcat项目启动报错

    Linux下Tomcat项目启动报错 org.springframework.beans.factory.CannotLoadBeanClassException: Error loading cla ...

  8. Eureka Server项目启动报错处理

    Eureka Server项目启动报错处理 Eureka是一个服务发现组件,提供服务注册.发现等注册中心功能,使用spring boot启动eureka应用时出现报错: 20:36:17.646 [r ...

  9. springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde

    springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde 创建 ...

随机推荐

  1. Exynos4412的外部中断是如何安排的?

    作者 彭东林 pengdonglin137@163.com   平台 Linux4.9 tiny4412   概述 结合tiny4412开发板分析一下Exynos4412的外部中断是如何组织的.   ...

  2. Javascript中的依赖注入

    首先通过带参函数来定义一个Javascript函数,相当于C#中的一个类. var Person = function(firstname, lastname){ this.firstname = f ...

  3. 升级WINDOWS10后任务栏的图标老是闪动是怎么回事

    解决方法:1.进入设置→更新和安全→恢复2.找到高级启动,点击“立即重启3.重启后,进入第一个选择画面,点击“疑难解答”4.然后点击“高级选项”5.在其中选择“启动设置”6.这里给出了下次重启后的主要 ...

  4. Mysql select语句设置默认值

    1.在没有设置默认值的情况下: SELECT userinfo.id, user_name, role, adm_regionid, region_name , create_time FROM us ...

  5. Js与正则表达式

    原本接着上面的章节,这一章节应该是写 Jquery事件的,由工作需要,暂时横插一篇正则表达式的学习,这里是边学边记录,错误之处,希望指正,提拔一二,不甚感激! 此章节有 1.1 正则表达式的定义 1. ...

  6. 使用SpringBoot的关于页面跳转的问题

    示例如下: @Controller public class UserController { @Resource UserService userService; @RequestMapping(& ...

  7. [转]如何在本地apache上架设多个站点

    http://dongxin1390008.blog.163.com/blog/static/3179247820094279581256/ 通常情况下,我们有时候需要架设多个站点 比如 我的web站 ...

  8. Java NIO SocketChannel

    A Java NIO SocketChannel is a channel that is connected to a TCP network socket. It is Java NIO's eq ...

  9. android自定义风格的toast

    先上图看一下我的自定义toast的样式 源码下载地址: CustomToastActivity.java源码 package com.jinhoward.ui_customtoast; /** * A ...

  10. 使用jQuery获取radio/checkbox组的值的代码收集

    <!-- $("document").ready(function(){ $("#btn1").click(function(){ $("[na ...