报错 …… are only available on JDK 1.5 and higher 错误(spring 的jdk版本检测在jdk 8下的修订)
正常方法
用更高的版本,因为spring向下兼容。
我公司需求的方法(真 迟早跑路)
1、在项目中创建一个package为org.springframework.core
2、在该package下面新建JdkVersion.java,内容如下:
package org.springframework.core; 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; } } }
3、到项目的WEB-INF/classes 下面找到对应的package中的JdkVersion.class文件
4、将项目中的spring-core-2.5.6.jar拷贝出来打开,然后将JdkVersion.class替换jar包中的该文件。
5、将修改后的spring-core-2.5.6.jar再覆盖到项目中。