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发现错误:
Unexpected exception parsing XML document from class path resource [applicationContext-dao.xml];
nested exception is 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
看源码是org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser自动检测,jdk版本检测时需要jre1.5以上版本,
但是JdkVersion只检查到了1.7,jre1.8 时不匹配任何jdk,按如下方法处理,可以解决问题。
1、在项目中创建一个package为org.springframework.core
2、在该package下面新建JdkVersion.java,内容如下:
package org.springframework.core;
public abstract class JdkVersion {
public static final int JAVA_13 = ;
public static final int JAVA_14 = ;
public static final int JAVA_15 = ;
public static final int JAVA_16 = ;
public static final int JAVA_17 = ;
//for jre 1.8
public static final int JAVA_18 = ;
private static final String javaVersion = System
.getProperty("java.version");
private static final int majorJavaVersion;
public static String getJavaVersion() {
return javaVersion;
}
public static int getMajorJavaVersion() {
return majorJavaVersion;
}
public static boolean isAtLeastJava14() {
return true;
}
public static boolean isAtLeastJava15() {
return getMajorJavaVersion() >= ;
}
public static boolean isAtLeastJava16() {
return getMajorJavaVersion() >= ;
}
static {
//for jre 1.8
if (javaVersion.indexOf("1.8.") != -) {
majorJavaVersion = ;
}else if (javaVersion.indexOf("1.7.") != -) {
majorJavaVersion = ;
} else if (javaVersion.indexOf("1.6.") != -) {
majorJavaVersion = ;
} else if (javaVersion.indexOf("1.5.") != -) {
majorJavaVersion = ;
} else {
majorJavaVersion = ;
}
}
}
3、到项目的WEB-INF/classes 下面找到对应的package中的JdkVersion.class文件

4、将项目中的spring-core-2.5.6.jar拷贝出来打开,然后将JdkVersion.class替换jar包中的该文件。(可以使用win rar打开jar包)
5、将修改后的spring-core-2.5.6.jar再覆盖到项目中。
这样就解决版本问题了。
spring低版本报错:java.lang.IllegalStateException: Context namespace element ‘annotation-config’ and its parser class [*] are only available on的更多相关文章
- nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' a
公司还用的是spring低版本,今天用jre 8测试了一下,发现错误: Unexpected exception parsing XML document from class path resour ...
- Spring Scheduled定时任务报错 java.lang.IllegalStateException: Encountered invalid @Scheduled method 'xxx': For input string: "2S"
报错信息如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ding ...
- Spring Boot单元测试报错java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]
1 报错描述 java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify @Boot ...
- 云笔记项目- 上传文件报错"java.lang.IllegalStateException: File has been moved - cannot be read again"
在做文件上传时,当写入上传的文件到文件时,会报错“java.lang.IllegalStateException: File has been moved - cannot be read again ...
- eclipse启动报错java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' befo
报错: java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invo ...
- Android - 错: java.lang.IllegalStateException: Already attached
错: java.lang.IllegalStateException: Already attached 本文地址: http://blog.csdn.net/caroline_wendy 可能原因: ...
- 解决spring boot启动报错java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level
解决spring boot启动报错java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level 学习了:https://blog.csdn. ...
- 使用RestTemplate时报错java.lang.IllegalStateException: No instances available for 127.0.0.1
我在RestTemplate的配置类里使用了 @LoadBalanced@Componentpublic class RestTemplateConfig { @Bean @LoadBalanced ...
- springboot测试启动报错java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
springboot测试启动报错: java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you ne ...
随机推荐
- 关于Cocos2d-x中监听物体不超越边界的解决方案
写一个监听器 touchlistener->onTouchMoved = [this](Touch* pTouch, Event*) { auto delta = pTouch->getD ...
- activiti小结
前提:业务流程复杂且流程频繁变更的,建议使用工作流:其他情况不建议使用. activiti(v5.14),工作流引擎,基于jbpm.使用建模语言BPMN2.0进行定义. 工作流数据需要写入数据库,ac ...
- 【Java面试题】35 List, Set, Map是否继承自Collection接口?
Collection是最基本的集合接口,声明了适用于JAVA集合(只包括Set和List)的通用方法. Set 和List 都继承了Conllection:Set具有与Collection完全一样的接 ...
- 【Java面试题】2 Java中使用final关键字修饰一个变量时,是引用不能变,还是引用的对象不能变?超详细解析
/* * 问题:使用final关键字修饰一个变量时,是引用不能变,还是引用的对象不能变 * 答: * 使用final关键字修饰一个变量时,是指引用变量不能变,引用变量所指向的对象中的内容还是可以改变的 ...
- c++ 类型定义
1. typedef map<int, CString> UDT_MAP_INT_CSTRING; UDT_MAP_INT_CSTRING enumMap;
- JUC回顾之-线程池的原理和使用
Java并发编程:线程池的使用 Java并发编程:线程池的使用 在前面的文章中,我们使用线程的时候就去创建一个线程,这样实现起来非常简便,但是就会有一个问题: 如果并发的线程数量很多,并且每个线程 ...
- EasyTouch的使用官方文档操作步骤
对于移动平台上的RPG类的游戏,我们常用虚拟摇杆来控制人物角色的行走和一些行为,相信我们对它并不陌生,之前尝试了EasyTouch2.5,发现并没有最新版的3.1好用,2.5版本的对于自适应没有做的很 ...
- 【MFC】OnInitDialog
OnInitDialog OnInitDialog是MFC的面向对象编程语言的类CDialog中的初始化成员函数名(虚函数).相当于对对话框进行初始化处理. 属 性 初始化成员函数名 处 ...
- 告诉你html5比普通html多了哪些东西?
- ros-indigo-desktop-full安装到ubuntu14.04
一.安装ros(原创博文,转载请标明出处-周学伟http://www.cnblogs.com/zxouxuewei/) 1.配置ubuntu的软件仓库.(可以不用进行配置). 配置你的 Ubuntu ...