您的位置:首页 > 编程语言 > Java开发

nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' a

2017-09-05 11:24 901 查看
公司还用的是spring低版本,今天用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。

网上招到了解决的方法,https://my.oschina.net/u/553266/blog/825103

网上的解决方法无非两种:降低jdk的版本或者修改spring-2.5.6.jar的源码.这些都不是我想要的。我查看了一下在spring-2.5.6jar的org\springframework\core\下有JdkVersion.class这个类,同时在spring-core.4.2.0.RELEASE也有这个类,所以在引入jar包的时候不需要引入spring-2.5.6jar只引入spring-core.4.2.0.RELEASE就行了。问题解决。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring namespace 源码 jar jdk
相关文章推荐