【转】Spring项目启动报"Could not resolve placeholder"解决方法
问题的起因:
除去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"解决方法的更多相关文章
- Spring项目启动报"Could not resolve placeholder"解决
1.问题的起因: 除去properites文件路径错误.拼写错误外,出现"Could not resolve placeholder"很有可能是使用了多个PropertyPlace ...
- spring项目启动报错BeanFactory not initialized or already closed
spring项目启动的时候报如下错误: java.lang.IllegalStateException: BeanFactory not initialized or already closed - ...
- 启动web项目,报内存不足错误的解决方法
Initialization of bean failed; nested exception is java.lang.OutOfMemoryError: Java heap space 原因: 在 ...
- spring项目启动报错
个人博客 地址:http://www.wenhaofan.com/article/20180921134534 错误信息 ERROR [localhost-startStop-1] - Context ...
- 【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 ...
- 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 ...
- Linux下Tomcat项目启动报错
Linux下Tomcat项目启动报错 org.springframework.beans.factory.CannotLoadBeanClassException: Error loading cla ...
- Eureka Server项目启动报错处理
Eureka Server项目启动报错处理 Eureka是一个服务发现组件,提供服务注册.发现等注册中心功能,使用spring boot启动eureka应用时出现报错: 20:36:17.646 [r ...
- 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 创建 ...
随机推荐
- 基于设备树的TQ2440 DMA学习(4)—— client驱动
作者 彭东林pengdonglin137@163.com 平台 TQ2440Linux-4.9 概述 前面分析了DMA控制器驱动,下面我们调用DMAENGINE的API写一个MEM2MEM的驱动 正文 ...
- CentOS MongoDB 高可用实战
原文:https://www.sunjianhua.cn/archives/centos-mongodb.html 一.MongoDB 单节点 1.1.Windows 版安装 1.1.1 获取社区版本 ...
- PPT幻灯片放映不显示备注,只让备注显示在自己屏幕上-投影机 设置
无论是老师或是讲师还是即将要演讲的人,在讲课之前一定会做好课件,到哪一页该讲哪些内容,到哪里该如何去讲等等.那么一般的讲师会将这些课件存放到哪里呢?是用个书本记载下来呢,还是直接存放到电脑上呢?其实本 ...
- Android Socket通信详解
一.Socket通信简介 Android与服务器的通信方式主要有两种,一是Http通信,一是Socket通信.两者的最大差异在于,http连接使用的是“请求—响应方式”,即在请求时建立连接通道,当客 ...
- Informix存储过程
一.存储过程概述 存储过程是一个用户定义的函数,由存储过程语句(SPL) 和一组SQL语句组成,以可以执行代码形式存储在数据库中,和表.视图.索引等一样,是数据库的一种对象. 存储过程语言SPL(St ...
- Convolutional Neural Networks at Constrained Time Cost(精读)
一.文献名字和作者 Convolutional Neural Networks at Constrained Time Cost,CVPR 2015 二.阅读时间 2015年6月30 ...
- 转: MySQL5.7 ERROR 1142 (42000)问题
1,mysql全库导入报错 [root@dev_121_21 ~]# mysql--socket=/usr/local/mysql/mysql.sock --default-character-set ...
- go1.8之安装配置具体步骤
操作系统: CentOS 6.9_x64 go语言版本: 1.8.3 安装go 这里直接安装二进制,其它方式请自行搜索. 1.下载并安装go 命令如下: ? 1 2 3 wget https://st ...
- pip 安装错误 'ascii' codec can't encode characters
安装 python-dev既可解决 apt-get install python-dev
- 出现Running Android Lint的错误
进入设置,让软件不要检查即可.