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

公司还用的是spring低版本,今天用jre 8测试了一下,发现错误:java

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。spring

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

 

网上的解决方法无非两种:下降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就好了。问题解决。测试

相关文章
相关标签/搜索