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


公司還用的是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就行了。問題解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM