Spring3.x版本多properties扫描异常记录
来源:互联网 发布:大公司程序员职业规划 编辑:程序博客网 时间:2024/05/18 02:30
今天部署服务时出现的问题,本次部署的服务包含多个spring工程,其中两个子项目都有properties的扫描配置。
日志:
Invalid bean definition with name 'xxxxx' defined in class path resource [xxxxxx.xml]: Could not resolve placeholder 'xxxxxxxx.host' in string value "${xxxxxxxx.host}" at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)[114:org.springframework.beans:3.2.5.RELEASE] at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.processProperties(PropertySourcesPlaceholderConfigurer.java:174)[116:org.springframework.context:3.2.5.RELEASE] at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:151)[116:org.springframework.context:3.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)[116:org.springframework.context:3.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)[116:org.springframework.context:3.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)[116:org.springframework.context:3.2.5.RELEASE] at com.travelsky.jcf.osgi.spring.SpringApplicationContextCreator$2.run(SpringApplicationContextCreator.java:360)[117:com.travelsky.jcf.osgi-spring:1.3.5] at com.travelsky.jcf.osgi.spring.util.OSGISpringHelper$1.run(OSGISpringHelper.java:57)[117:com.travelsky.jcf.osgi-spring:1.3.5] at java.lang.Thread.run(Thread.java:745)[:1.8.0_73]
单从日志上看,一开始只想到了是不是配置文件key的命名错了啊之类的,并没有想太多。之后发现问题的原因是在 context:property-placeholder
配置上
错误的配置:
1.<context:property-placeholder location="file:./xxx/config/xxx.properties"/>2.<context:property-placeholder location="file:./xxx/config/xxx2.properties" ignore-unresolvable="true" />
程序走到配置1,完成扫描是没有问题的,但走到配置二时便会报上面的错误,最后的问题是 少写了ignore-unresolvable=”true” 引起的。
具体的原因看到基本上说是因为占位符冲突的原因。导致冲突的原因可能是这样的:实例化了多个properties对象,按照初始化顺序,依次匹配${key},配置了ignore-unresolvable=”true” 的properties实例在发现匹配失败后便继续下一个,而未配置的则停止报错,导致真正的所需的properties实例无法配置。
阅读全文
0 0
- Spring3.x版本多properties扫描异常记录
- Spring3.x 获取properties资源文件的值
- Spring3.X <form:form>标签数据绑定常见异常解决方法
- spring3.x
- Spring3.x 版本和 JDK1.8 不兼容
- 【JAVA笔记】spring3.x配置--每天23:30分执行任务 & log4j.properties的配置
- mule3.X + spring3.X
- Spring 4.X 版本 json配置记录
- spring3 常见异常解决
- Spring3 MVC 异常处理
- Spring3 Mybatis 异常处理
- spring3 常见异常解决
- spring3 常见异常解决
- spring3 常见异常解决 .
- Spring3 Mybatis 异常处理
- Spring3.1异常处理
- spring3 常见异常解决
- spring3 常见异常解决
- android studio初次见面,多多关照
- 被选择性遗忘的共享充电宝
- python学习笔记
- Codeforces 797A k-Factorization
- ORACLE的不完全恢复
- Spring3.x版本多properties扫描异常记录
- Jdk7u21 反序列化漏洞Gadget原理
- mongoDB修改数据
- 利用AOP加注解的形式完成代码的优化
- AngularJS 动态添加展示数据
- 快速排序
- Java 验证请求数据完整性信息
- 乱码问题详解2
- scikit-learn 中文文档-交叉分解-监督学习|ApacheCN