spring (2.5, 3.2) 在 jre 1.8下的fix
来源:互联网 发布:维珍澳航 知乎 编辑:程序博客网 时间:2024/06/10 10:57
摘要
spring 的jdk版本检测在jdk 8下的修订
公司还用的是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, 修正如下,问题解决
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; } }}
转自 http://my.oschina.net/aruan/blog/210284
参考: http://stackoverflow.com/questions/23813369/spring-java-error-namespace-element-annotation-config-on-jdk-1-5-and-high
0 0
- spring (2.5, 3.2) 在 jre 1.8下的fix
- spring 2.5 在 jre 1.8下的error
- [转帖]JRE在linux下的安装与配置步骤
- 在只有JRE的环境下使用BTrace
- 在只有JRE的环境下使用BTrace
- Ubuntu下jre的安装
- Eclipse启动的时候,需要jre,因此只要将jre放在eclipse.exe即eclipse.ini目录下,即可,但是,文件夹名称一定要是jre,不能重命名
- javascript在firefox下测试JRE
- 在linux下安装tomcat和jre
- Eclipse添加jdk下的jre和jre的区别
- jquery和spring和jre的关联
- 在jdk1.7安装目录下jre\lib找不到tools.jar的解决办法
- ubuntu下安装jre的步骤
- ubuntu下安装jre的步骤
- openSUSE下配置Eclipse的JRE
- ubuntu下安装jre的步骤
- ubuntu下安装jre的步骤
- ubuntu下安装jre的步骤
- HDU:3665 Seaside(dijkstra算法求最短路径)
- 分拆素数和
- POJ 3268Silver Cow Party
- find_if_not 源码剖析
- 神经网络:学习(2)
- spring (2.5, 3.2) 在 jre 1.8下的fix
- LinkedList的源码分析
- Kafka集群搭建02-Kafka 集群部署
- 数学 ( 容斥原理&&求区间内互质数的个数)——Co-prime ( HDU 4135 )
- listview添加footerview的注意事项
- poj 2488 A Knight's Journey
- 树莓派与电脑之间文件传输
- POJ2524-Ubiquitous Religions
- 1105. Spiral Matrix (25)-PAT甲级真题