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/applicationContext-db.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版本的spring不支持注解,有两种方式解决这个问题。一是 换jdk,二是 加一个配置文件。
这里使用的是加一个配置文件:在src文件夹加org.springframework.core包,并添加一个JdkVersion.java文件,使注解能够识别jdk8。
JdkVersion.java文件内容如下:
package org.springframework.core; /**
* Internal helper class used to find the Java/JVM version
* that Spring is operating on, to allow for automatically
* adapting to the present platform's capabilities.
*
* <p>Note that Spring requires JVM 1.5 or higher, as of Spring 3.0.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Rick Evans
*/
public abstract class JdkVersion { /**
* Constant identifying the 1.3.x JVM (JDK 1.3).
*/
public static final int JAVA_13 = 0; /**
* Constant identifying the 1.4.x JVM (J2SE 1.4).
*/
public static final int JAVA_14 = 1; /**
* Constant identifying the 1.5 JVM (Java 5).
*/
public static final int JAVA_15 = 2; /**
* Constant identifying the 1.6 JVM (Java 6).
*/
public static final int JAVA_16 = 3; /**
* Constant identifying the 1.7 JVM (Java 7).
*/
public static final int JAVA_17 = 4; /**
* Constant identifying the 1.8 JVM (Java 8).
*/
public static final int JAVA_18 = 5; private static final String javaVersion; private static final int majorJavaVersion; static {
javaVersion = System.getProperty("java.version");
// version String should look like "1.4.2_10"
if (javaVersion.contains("1.8.")) {
majorJavaVersion = JAVA_18;
}else if (javaVersion.contains("1.7.")) {
majorJavaVersion = JAVA_17;
}
else if (javaVersion.contains("1.6.")) {
majorJavaVersion = JAVA_16;
}
else {
// else leave 1.5 as default (it's either 1.5 or unknown)
majorJavaVersion = JAVA_15;
}
} /**
* Return the full Java version string, as returned by
* <code>System.getProperty("java.version")</code>.
* @return the full Java version string
* @see System#getProperty(String)
*/
public static String getJavaVersion() {
return javaVersion;
} /**
* Get the major version code. This means we can do things like
* <code>if (getMajorJavaVersion() < JAVA_14)</code>.
* @return a code comparable to the JAVA_XX codes in this class
* @see #JAVA_13
* @see #JAVA_14
* @see #JAVA_15
* @see #JAVA_16
* @see #JAVA_17
*/
public static int getMajorJavaVersion() {
return majorJavaVersion;
} /**
* Convenience method to determine if the current JVM is at least Java 1.4.
* @return <code>true</code> if the current JVM is at least Java 1.4
* @deprecated as of Spring 3.0 which requires Java 1.5+
* @see #getMajorJavaVersion()
* @see #JAVA_14
* @see #JAVA_15
* @see #JAVA_16
* @see #JAVA_17
*/
@Deprecated
public static boolean isAtLeastJava14() {
return true;
} /**
* Convenience method to determine if the current JVM is at least
* Java 1.5 (Java 5).
* @return <code>true</code> if the current JVM is at least Java 1.5
* @deprecated as of Spring 3.0 which requires Java 1.5+
* @see #getMajorJavaVersion()
* @see #JAVA_15
* @see #JAVA_16
* @see #JAVA_17
*/
@Deprecated
public static boolean isAtLeastJava15() {
return true;
} /**
* Convenience method to determine if the current JVM is at least
* Java 1.6 (Java 6).
* @return <code>true</code> if the current JVM is at least Java 1.6
* @deprecated as of Spring 3.0, in favor of reflective checks for
* the specific Java 1.6 classes of interest
* @see #getMajorJavaVersion()
* @see #JAVA_16
* @see #JAVA_17
*/
@Deprecated
public static boolean isAtLeastJava16() {
return (majorJavaVersion >= JAVA_16);
} }
Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher的更多相关文章
- 【原创】大叔经验分享(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 ...
- [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 ...
- 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. ...
- 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 'annot ...
- 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 ...
- 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 ...
- 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 ...
- 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 Boot] Use Component Scan to scan for Bean
Component Scan is important concept when we want to create Bean. Currently we know what, for the cla ...
随机推荐
- C#键盘事件处理父窗体子窗体
: : MessageBox.Show(, , Keys.F1); ...
- Verilog 加法器和减法器(8)-串行加法器
如果对速度要求不高,我们也可以使用串行加法器.下面通过状态机来实现串行加法器的功能. 设A=an-1an-2-a0, B=bn-1bn-2-b0,是要相加的两个无符号数,相加的和为:sum=sn-1s ...
- yum离线安装rpm包
CentOS利用yum下载好rpm包,并离线安装 1.联网安装好rpm包,并将下载好的包备好 #yum install --downloadonly --downloaddir=/home/sam ...
- DNS缓存中毒是怎么回事?
近来,网络上出现互联网漏洞——DNS缓存漏洞,此漏洞直指我们应用中互联网脆弱的安全系统,而安全性差的根源在于设计缺陷.利用该漏洞轻则可以让用户无法打开网页,重则是网络钓鱼和金融诈骗,给受害者造成巨大损 ...
- flex bison
https://www.gnu.org/software/bison/manual/bison.html https://blog.csdn.net/sirouni2003/article/detai ...
- google guice @inject comments
refer this document: http://blog.chinaunix.net/uid-20749563-id-718418.html @Inject注入方式,用@Inject来标识那个 ...
- 如何制作initrd.img文件
2008-11-12 16:02:37 initrd.img文件是redhat,mandrake等linux发布使用的内存镜像文件.镜像中是一个微型系统.在安装系统时,将initrd.img展开 ...
- 译:7.使用Spring MVC服务Web内容
本指南向您介绍了使用Spring创建“hello world”网站的过程.阅读原文:Serving Web Content with Spring MVC 1. 你将会构建什么? 您将构建一个具有静态 ...
- VirtualBox 端口转发 SSH
在服务器上安装VirtualBox并配置转发: VirtualBox网络连接方式,选择默认的NAT连接方式. 在下面有个 “端口转发” 按钮,点击配置主机到虚拟机的端口映射. ref: http:// ...
- ECMAScript 6 入门之变量的解构赋值
1.数组 1. var a=1,b=2,c=3; console.log("a:",a) console.log("b:",b) console.log(&qu ...