Spring/Java error: namespace element 'annotation-config' … on JDK 1.5 and higher

后端 未结 11 1199
Happy的楠姐
Happy的楠姐 2020-11-29 00:47

I have Spring/Java App that is compiled with Compiler compliance level 1.5.

I have a new Linux setup where I downloaded Apache Tomcat 8.0.8<

11条回答
  •  旧时难觅i
    2020-11-29 01:38

    I have the similar problem. Old Spring MVC/Spring Faces application under spring 2.5.5 doesn't run on Java 8.

    I spent few days trying to find solution because we need to run Java 8.

    First idea was: to upgrade complete Spring package up to 4.1.6. I used Maven. Problem of this method that after that it is necessary to rework nearly the whole project. It is because for example in Spring 4 were removed JSF implementation and some special taglibs where completely removed, like . And were some more major and minor problems with configuration, adapters, handlers, mappings....

    Second approach was to replace Spring JARs partially.One by one. Again no success. Impossible to replace any jar without touching dependencies.

    I believe that after few weeks or monthes of struggling I can get success on both approaches. But have no so much time. And I gave up. My solution is:

    I found source file JdkVersion.java from org.springframework.core package. http://www.java2s.com/Code/Jar/o/Downloadorgspringframeworkcoresources300releasejar.htm. I created org.springframework.core package in my project with only one class JdkVersion. After that made simple change of the code to check Java 8 version. Smth like that:

    public static final int JAVA_18 = 5;
    

    ...

            javaVersion = System.getProperty("java.version");
        // version String should look like "1.4.2_10"
        if (javaVersion.contains("1.8.")) {
            majorJavaVersion = JAVA_18;         
            System.out.println("JAVA_VERSION: "+javaVersion);
    
        } else if (javaVersion.contains("1.7.")) {
            majorJavaVersion = JAVA_17;
        }
    

    Even this code change is not really necessary, only just for fun.It is because this source came from Spring 3.0.0 package where Spring guys already changed the Java version check. Versions higher than 7 are not considered as old java.

    Now application starts properly. It call JdkVersion class from my project instead of jar.

    Works so far! Thanks for all from this thread who gave this idea.

    Thanks

提交回复
热议问题