zoukankan      html  css  js  c++  java
  • 解决AnnotationTransactionAttributeSource is only available on Java 1.5 and highe

    由于项目需要把jdk升级成为了jdk8,在eclipse中导入一个jdk1.6的项目,启动tomcat的时候,报错:

    AnnotationTransactionAttributeSource is only available on Java 1.5 and highe

    想要解决这个错误,一般有两种办法:

    1、将jdk8换成jdk7,重新启动项目就好了(由于另一个项目必须是jdk1.8,所以降版本不现实)。

    2、第二种手动修改spring的jar包,在org.springframework.core目录下,有一个JdkVersion.class,自己参照包路径,重新写一个JdkVersion.java,如下所示:


        package org.springframework.core;
         
        public 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;
                }
            }
        }


    写好之后,编译成.class文件,放到spring的jar包中,替换项目jar包,重新启动,就好了。

  • 相关阅读:
    204. Count Primes (Integer)
    203. Remove Linked List Elements (List)
    202. Happy Number (INT)
    201. Bitwise AND of Numbers Range (Bit)
    200. Number of Islands (Graph)
    199. Binary Tree Right Side View (Tree, Stack)
    198. House Robber(Array; DP)
    191. Number of 1 Bits (Int; Bit)
    190. Reverse Bits (Int; Bit)
    189. Rotate Array(Array)
  • 原文地址:https://www.cnblogs.com/llfddmm/p/10521113.html
Copyright © 2011-2022 走看看