Redis配置错误(已解决) Could not resolve placeholder 'redis.maxIdle' in string value ${redis.maxIdle}
错误信息
使用Redis 时遇到Could not resolve placeholder ‘redis.maxIdle’ in string value "${redis.maxIdle}"错误。可以肯定的是 读取配置文件时获取。
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'poolConfig' defined in URL [jar:file:/D:/repository_huanletao/com/hlt/hlt-common/1.0-SNAPSHOT/hlt-common-1.0-SNAPSHOT.jar!/spring/applicationContext-redis.xml]: Could not resolve placeholder 'redis.maxIdle' in string value "${redis.maxIdle}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'redis.maxIdle' in string value "${redis.maxIdle}"at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211)at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.processProperties(PropertySourcesPlaceholderConfigurer.java:177)at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:152)at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:166)at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520)at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)at java.util.concurrent.FutureTask.run(FutureTask.java:266)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'redis.maxIdle' in string value "${redis.maxIdle}"at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:204)at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:178)at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:172)at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:282)at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:204)at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:141)at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:82)at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:208)... 18 more九月 07, 2019 9:51:33 上午 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
九月 07, 2019 9:51:33 上午 org.apache.catalina.core.StandardContext startInternal
严重: Context [] startup failed due to previous errors
九月 07, 2019 9:51:33 上午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
九月 07, 2019 9:51:34 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
九月 07, 2019 9:51:34 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [] registered the JDBC driver [com.mysql.fabric.jdbc.FabricMySQLDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
九月 07, 2019 9:51:34 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
九月 07, 2019 9:51:34 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [] registered the JDBC driver [com.alibaba.druid.mock.MockDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
九月 07, 2019 9:51:34 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
九月 07, 2019 9:51:34 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-9002"]
解决方式
原因是在多个子项目中都加载了配置文件,例如DAO加载了数据库相关的配置文件。最开始的加载配置文件代码如下图:
将所有的加载配置文件的代码修改成下面的形式就好了(必须所有的加载方式一样):
<!-- 加载配置文件 --><context:property-placeholder location="classpath*:properties/*.properties" />
DAO的加载配置文件:
Redis加载配置文件:
错误原因
context:property-placeholder标签提供了一种优雅的外在化参数配置的方式,不过该标签在Spring配置文件中只能存在一份。
Spring容器是采用反射扫描的发现机制,通过标签的命名空间实例化实例,当Spring探测到容器中有一个,org.springframework.beans.factory.config.PropertyPlaceholderCVonfigurer的Bean就会停止对剩余PropertyPlaceholderConfigurer的扫描,即只能存在一个实例。
大概意思是,例如dao加载了db.properties配置文件
<!-- 加载配置文件 --><context:property-placeholder location="classpath:properties/db.properties" />
那么就不会再去加载其他的配置文件,想要加载其他的就需要这样写:
<!-- 加载配置文件 多个文件用,隔开 --><context:property-placeholder location="classpath*:properties/*.properties,xxx.properties" />
但是我们需要的是Redis的配置文件,它并不在当前的DAO的classpath下面,所以需要这样来加载配置文件:
<!-- 加载配置文件 --><context:property-placeholder location="classpath*:properties/*.properties" />
Redis配置错误(已解决) Could not resolve placeholder 'redis.maxIdle' in string value ${redis.maxIdle}相关推荐
- Could not resolve placeholder jdbc.driver in string value ${jdbc.driver}
applicationContext 加载properties类型的配置文件的问题 错误信息:Could not resolve placeholder 'jdbc.driver' in string ...
- spring读取多个配置properties报错“Could not resolve placeholder“的解决方案
spring读取多个配置properties报错"Could not resolve placeholder"的解决方案 参考文章: (1)spring读取多个配置properti ...
- Could not resolve placeholder 'jdbc username' in string valu
分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 1.错误 ...
- 关机提示错误(已解决) 0x0074006e指令引用的0x0074006e内存不为read
问题(已解决):关机提示 0x0074006e指令引用的0x0074006e内存不为read 2012年12月19日 我的解决过程 1.回忆问题出现之前的可疑操作 修改虚拟内存,将系统盘内存(大小已忘 ...
- CC送人气票显示服务器错误,[已解决]用户尝试创建新帐户时出现“服务器错误” - Magento 1.7...
当用户尝试创建一个新的帐户,他们填写自己的信息上/客户/帐号/创建页面就好了,然后当他们点击提交,他们得到这500错误: The website encountered an error while ...
- oracle 配置数据库错误,Oracle数据库配置错误信息解决方法
Oracle数据库配置错误信息 Oralce数据库的错误信息经常会出现,我们看见的都是错误的代码,至于错误原因究竟是什么还一时半会难以解答,所以就把一些常见的错误整理了一下,来看看也许对你有帮助的. ...
- 解决 Could not resolve placeholder ‘xxx‘ in string value “${xxx}“
这个其实也算是个小问题,就是拿来记录一下. 原文地址:https://blog.csdn.net/u012198209/article/details/88965922 一般来说报Could not ...
- DATAGUARD配置错误的解决日志
在一个SHELL窗口打开 STANDBY 数据库: SQL> startup nomount ORACLE instance started. Total System Global Area ...
- 出现Avoid mutating a prop directly since the value will错误 已解决
出现这种情况的原因是我们直接改变子组件的props值,众所周知,props是父向子传值的一种形式.当我们子组件的props值要改变的时候,不能直接通过改变子组件的props来改变父组件. 例如: 父组 ...
最新文章
- VScode快速一键生成html、vue、jsx、ajax、sass、docker等代码片段
- eclipse插件之easyshell
- cp无法获取文件状态stat_Node.js从零开始——文件系统
- 汉字正字表达式解决方案
- C语言 const 修饰指针 - C语言零基础入门教程
- pictureBox1.Image的获得图片路径的三种方法
- windows2003开机自动登陆桌面
- 那么问题来了,什么才是正确的?我们就是为问题而生的
- R语言和Python交互
- 如何注册谷歌账号、邮箱(22.8.23亲测可用)
- 高中数学学习技巧,这几步你都做到了吗?
- 阅读笔记04——魔鬼搭讪学
- OAuth 2.0设计(以微信登录为例)
- codeforces 722C Destroying Array
- PC端微信扫码支付二维码生成接口的调整
- Comparative Molecular Analysis of Gastrointestinal Adenocarcinomas
- 在微型计算机中cmos是什么,什么事cmos?
- Oday安全 11.5利用未启用SafeSEH模块绕过SafeSEH一节注记
- LED和LCD,LED和OLED,AMOLED和OLED有什么区别
- 清理autodesk产品注册表_关于Autodesk软件的删除方法