spring 2.5.6 错误:Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
在运行一个第三方公司交付的项目的时候, 出现:
Caused by: java.lang.IllegalStateException: Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
at org.springframework.context.config.ContextNamespaceHandler$1.parse(ContextNamespaceHandler.java:65)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
at
凭感觉,这是jdk版本问题。 我本机安装的是1.8, 对方要求的也是1.8. 他们运行没问题,我这里怎么就不行了呢? 这就奇怪了。。
跟进源码里面看看吧: org.springframework.context.config.ContextNamespaceHandler$1.parse(ContextNamespaceHandler.java:65)
private void registerJava5DependentParser(final String elementName, final String parserClassName) {
BeanDefinitionParser parser = null;
if(JdkVersion.isAtLeastJava15()) {
try {
Class parserClass = ClassUtils.forName(parserClassName, ContextNamespaceHandler.class.getClassLoader());
parser = (BeanDefinitionParser)parserClass.newInstance();
} catch (Throwable var5) {
throw new IllegalStateException("Unable to create Java 1.5 dependent parser: " + parserClassName, var5);
}
} else {
parser = new BeanDefinitionParser() {
public BeanDefinition parse(Element element, ParserContext parserContext) {
throw new IllegalStateException("Context namespace element '" + elementName + "' and its parser class [" + parserClassName + "] are only available on JDK 1.5 and higher");
}
};
}
很明显是JdkVersion.isAtLeastJava15() 有蹊跷:
public static boolean isAtLeastJava15() {
return getMajorJavaVersion() >= 2;
}
最后找到:
static {
if(javaVersion.indexOf("1.7.") != -1) {
majorJavaVersion = 4;
} else if(javaVersion.indexOf("1.6.") != -1) {
majorJavaVersion = 3;
} else if(javaVersion.indexOf("1.5.") != -1) {
majorJavaVersion = 2;
} else {
majorJavaVersion = 1;
}
}
原来如此,这个版本的spring(2.5.6) 只能支持到 1.7, 估计当时1.8 没有出来(什么年代了还用2.5.6,真是奇葩啊)。怎么办呢?需要重新安装一个低版本的jdk啊
另外注意到:
private static final String javaVersion = System.getProperty("java.version");
还需要,修改 java的 环境变量,不然还是不生效。
spring 2.5.6 错误:Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher的更多相关文章
- Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
异常信息如下: 错误: Unexpected exception parsing XML document from class path resource [spring/applicationCo ...
- 【原创】大叔经验分享(16)Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
今天尝试运行一个古老的工程,配置好之后编译通过,结果运行时报错: org.springframework.beans.factory.BeanDefinitionStoreException: Une ...
- class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
在搭建SSM项目时报了以下的错误: 06-Oct-2019 11:55:52.109 信息 [RMI TCP Connection(5)-127.0.0.1] org.apache.catalina. ...
- [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher 问题--MyEclipse设置JDK版本
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML doc ...
- spring低版本报错:java.lang.IllegalStateException: Context namespace element ‘annotation-config’ and its parser class [*] are only available on
参考来源:http://blog.csdn.net/sunxiaoyu94/article/details/50492083 使用spring低版本(2.5.6),使用jre 8发现错误: Unexp ...
- nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' a
公司还用的是spring低版本,今天用jre 8测试了一下,发现错误: Unexpected exception parsing XML document from class path resour ...
- Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser]
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
- Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
Context namespace element 'annotation-config' and its parser class [org.springframework.context.anno ...
- …… are only available on JDK 1.5 and higher 错误
"C:\Program Files\Java\jdk1.8.0_73\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 &q ...
随机推荐
- linux下lampp的启动和停止脚本
今天试着写了lampp的启动停止脚本,和上一篇的tomcat的启动停止有一点小区别,就是lampp启动之后有很多的进程号,如果按照tomcat的停止脚本写就会出错,下面做细细的介绍 1.lampp的停 ...
- 【转载】 spring事物配置,声明式事务管理和基于@Transactional注解的使用
https://blog.csdn.net/bao19901210/article/details/41724355
- QT+VS2013 * 获取网络时间
使用qt函数获取网络时间 现在Qt Project Setting中的Qt Modules勾选NetWork,再导入头文件我也忘了叫什么了 QStringList net_time; QTcpSock ...
- spring-aop思想实践demo
需求: 例如我们需要有一个类中每个方法执行前都需要做一个权限校验,必须是有特定权限的账号才能完成该方法的操作. 解决方案: 1.使用父类继承方式,书写该类的父类,然后在父类中定义一个checkPri的 ...
- python函数之可迭代对象、迭代器的判断
怎么判断一个对象是可迭代对象还是迭代器 例子 from collections import Iterable, Iterator lst = ['Today is Wednesday', 'Tomo ...
- 关于WebService
转自于:https://www.cnblogs.com/xdp-gacl/p/4048937.html 一.序言 大家或多或少都听过 WebService(Web服务),有一段时间很多计算机期刊.书籍 ...
- 在kerberos认证过程中Active Directory的作用
LDAP介绍 1),ladp(Lightweight Directory Access Protocol),轻量级目录访问协议,提供被称为目录服务的信息服务,特别是基于X.500(构成全球分布式的目录 ...
- FirewallD 快速使用文档
FirewallD简介 FirewallD是CentOS7系列上代替iptables管理netfilter的配置工具,提供图形化和命令行,使用python开发(新版中计划使用c++重写),提供图形化和 ...
- 树莓派3代B+安装mateubuntu16.04
直接安装会卡在开机后的彩虹界面 所以先直接安装:2019-04-08-raspbian-stretch-lite.img 安装完毕后,直接在Linux环境下读取 /boot /系统分区(系统分区在wi ...
- 利用redis List队列简单实现秒杀 PHP代码实现
一 生产者producer部分 --------------------------------producer 部分注释--------------------------------------- ...