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
Spring项目启动报"Could not resolve placeholder"解决的更多相关文章
- 【转】Spring项目启动报"Could not resolve placeholder"解决方法
问题的起因: 除去properites文件路径错误.拼写错误外,出现"Could not resolve placeholder"很有可能是使用了多个PropertyPlaceho ...
- spring项目启动报错BeanFactory not initialized or already closed
spring项目启动的时候报如下错误: java.lang.IllegalStateException: BeanFactory not initialized or already closed - ...
- 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 创建 ...
- SpringBoot项目启动报错:java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | ...
随机推荐
- 《Fluent Python》---一个关于memoryview例子的理解过程
近日,在阅读<Fluent Python>的第2.9.2节时,有一个关于内存视图的例子,当时看的一知半解,后来查了一些资料,现在总结一下,以备后续查询: 示例复述 添加了一些额外的代码,便 ...
- 【Offer】[29] 【顺时针打印矩阵】
题目描述 思路分析 测试用例 Java代码 代码链接 题目描述 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字. 例如,如果输入如下矩阵:  则依次打印出数字1,2,3,4,8,12, ...
- explain的关键字段的意义
mysql提供的explain工具可以输出一些有用的信息. 一下是相关的部分返回值的意义. select_type 表示SELECT的类型,常见的取值有: SIMPLE:简单表,不使用表连接或子查询 ...
- .net core Cookie的使用
缘起: 公司领导让我做一个测试的demo,功能大概是这样的:用户通过微信扫一扫登陆网站,如果用户登录过则直接进入主界面,否则就保留在登录界面. 实现方法: 首先先把网站地址生成个二维码,在扫描二维码后 ...
- 错误:java.lang.Exception: No tests found matching Method testPrePage1(egou_manager_web.TestEBrand) from org.junit.internal.requests.ClassRequest@4f3cc73c
今天测试分页时出现以下错误: java.lang.Exception: No tests found matching Method testPrePage1(egou_manager_web.Tes ...
- 列表ListView和ListActivity以及使用SimpleAdapter
创建listview有2种方式 1>直接使用ListView进行创建 2>让Activity继承ListActivity 下面是listview常用的一些属性 案例: public cla ...
- Java线程的几种状态(基于Oracle jdk 1.8)
Java中线程的状态定义在java.lang.Thread类中的一个枚举中. public enum State { /** * Thread state for a thread which has ...
- caffe学习二:py-faster-rcnn配置运行faster_rcnn_end2end-VGG_CNN_M_1024 (Ubuntu16.04)
本文的主要目的是学习记录. 原文连接:https://blog.csdn.net/samylee/article/details/51099508 本博客中我将对py-faster-rcnn配置运行f ...
- 【iOS】得到当前年、月、周的第一天和最后一天
在写一个记账软件,其中有个统计功能.比如,统计某月的支出,需要知道某天所在的月的第一天和最后一天,以便从数据库中根据时间取数据. 话不多说,上代码: // // EBDate.h // ChargeM ...
- GStreamer基础教程08 - 多线程
摘要 GStreamer框架会自动处理多线程的逻辑,但在某些情况下,我们仍然需要根据实际的情况自己将部分Pipeline在单独的线程中执行,本文将介绍如何处理这种情况. GStreamer多线程 GS ...