…… are only available on JDK 1.5 and higher 错误
2017-02-19 19:54
465 查看
小编在项目中整合spring和struts2时,出现了这种错误:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [D:\tomcat-7.0.67\webapps\ItcastOA\WEB-INF\classes\applicationContext.xml]; nested exception
is java.lang.IllegalStateException: Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
因为JDK版本检测时需要jre1.5以上版本,但JdkVersion只检查到了1.7,jre1.8 时不匹配任何jdk,按如下方法处理,可以解决问题。
以下是小编的解决方案:
1.在项目中创建一个package包为org.springframework.core,为下面的文件建立做准备;
2.在刚刚新建的包下添加一个JdkVersion.java类,编辑如下内容:
4.将项目中的spring-core-2.5.6.jar拷贝出来打开,然后将其中的JdkVersion.class文件替换掉;
5.重新将修改后的spring-core-2.5.6.jar包覆盖到项目中。
到这一步,重新启动项目,就不会有错误了。
大家可以试试,期待可以有更多的方案一起分享!
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [D:\tomcat-7.0.67\webapps\ItcastOA\WEB-INF\classes\applicationContext.xml]; nested exception
is java.lang.IllegalStateException: Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
因为JDK版本检测时需要jre1.5以上版本,但JdkVersion只检查到了1.7,jre1.8 时不匹配任何jdk,按如下方法处理,可以解决问题。
以下是小编的解决方案:
1.在项目中创建一个package包为org.springframework.core,为下面的文件建立做准备;
2.在刚刚新建的包下添加一个JdkVersion.java类,编辑如下内容:
package org.springframework.core; public abstract class JdkVersion { public static final int JAVA_13 = 0; public static final int JAVA_14 = 1; public static final int JAVA_15 = 2; public static final int JAVA_16 = 3; public static final int JAVA_17 = 4; //for jre 1.8 public static final int JAVA_18 = 5; 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() >= 2; } public static boolean isAtLeastJava16() { return getMajorJavaVersion() >= 3; } static { //for jre 1.8 if (javaVersion.indexOf("1.8.") != -1) { majorJavaVersion = 5; }else 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; } } }3.在项目的WEB-INF/classes下找到刚刚新建包中对应的JdkVersion.class文件;
4.将项目中的spring-core-2.5.6.jar拷贝出来打开,然后将其中的JdkVersion.class文件替换掉;
5.重新将修改后的spring-core-2.5.6.jar包覆盖到项目中。
到这一步,重新启动项目,就不会有错误了。
大家可以试试,期待可以有更多的方案一起分享!
相关文章推荐
- …… are only available on JDK 1.5 and higher 错误(spring 的jdk版本检测在jdk 8下的修订)
- …… are only available on JDK 1.5 and higher 错误(spring 的jdk版本检测在jdk 8下的修订)
- …… are only available on JDK 1.5 and higher 错误
- …… are only available on JDK 1.5 and higher 错误(spring 的jdk版本检测在jdk 8下的修订)
- …… are only available on JDK 1.5 and higher 错误(spring 的jdk版本检测在jdk 8下的修订)
- [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher 问题--MyEclipse设置JDK版本
- spring2.5.6的‘annotation-config’ and its parser class are only available on JDK 1.5 and higher错误解决
- Spring 的 jdk 版本检测在 jdk 8 下的修订:only available on JDK 1.5 and higher 错误
- Spring 注解:element 'annotation-config' and its parser class are only available on JDK 1.5 and higher
- 解决Spring注解错误:ComponentScanBeanDefinitionParser are only available on JDK 1.5 and higher
- AnnotationConfigBeanDefinitionParser are only available on JDK 1.5 and higher
- tomcat启动报are only available on JDK 1.5 and higher错误
- Context namespace element 'component-scan' its parser class are only available on JDK 1.5 and higher
- 关于 AnnotationConfigBeanDefinitionParser are only available on JDK 1.5 and higher
- AnnotationConfigBeanDefinitionParser are only available on JDK 1.5 and higher
- [转]Tomcat启动报错:AnnotationConfigBeanDefinitionParser are only available on JDK 1.5 and higher
- annotationconfigbeandefinitionparser are only available on jdk 1.5 and higher
- idea报错:……are only available on JDK 1.5 and higher
- ....are only available on JDK 1.5 and higher
- only available on JDK 1.5 and higher at * org.springframework.beans.factory.