【转】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 创建 ...
随机推荐
- jQuery把所有被选中的checkbox的某个属性值连接成字符串
有这样的一个需求:对于一组checkbox,当点击每个checkbox后,把当前处于选中状态的checkbox的某个属性值取出来连接成字符串,并以逗号分开. html部分: <input typ ...
- Android中的"Unable to start activity ComponentInfo"错误
在调试的过程中发现一直报这个错误"Unable to start activity ComponentInfo",从字面的意思看是无法启动某个activity组件,但是看了mani ...
- SMTP协议及POP3协议-邮件发送和接收原理(转)
本文转自https://blog.csdn.net/qq_15646957/article/details/52544099 感谢作者 一. 邮件开发涉及到的一些基本概念 1.1.邮件服务器和电子邮箱 ...
- 在Android.mk文件中输出打印消息
http://www.xuebuyuan.com/1947880.html 在进行Android NDK的开发当中有时想看看Android.mk文件当中某个变量的值,可以再Android.mk文件当中 ...
- 初识安卓小程序(Android电话拨号器)
首先,先创建一个安卓项目(我的版本号是4.4.2的),名字为"电话拨号器",创建的时候点击"clipart",如图: 然后在res目录下找到layout目录,找 ...
- clojure中符号symbols 和变量vars的正确理解
原地址 http://stackoverflow.com/questions/11662084/why-does-clojure-distinguish-between-symbols-and-va ...
- git 删除远程分支和本地分支
删除远程分支和本地分支 https://www.cnblogs.com/luosongchao/p/3408365.html 将远程git仓库里的指定分支拉取到本地(本地不存在的分支) https:/ ...
- 新闻编辑室第三季/全集The Newsroom迅雷下载
第三季 The Newsroom Season 3 (2014)看点:今日他们终于公布了续订第三季的消息,但同时也宣称第三季将会是<新闻编辑室>的最终季,对剧迷们来说可谓苦乐参半.讲述了一 ...
- geth 命令
{ admin: { datadir: "/home/.ethereum/.ethereum", nodeInfo: { enode: "enode://a974839a ...
- [Android] Implementation vs API dependency
原文链接: https://jeroenmols.com/blog/2017/06/14/androidstudio3/ https://blog.csdn.net/lonewolf521125/ar ...