Java 8 Spring compatibility

前端 未结 4 994
挽巷
挽巷 2020-11-29 11:21

I am currently migrating my application from Java 7 to Java 8 and currently I am running the Spring 3.1.6 jar. Would this be compatible with Java 8 or I need to upgr

4条回答
  •  一个人的身影
    2020-11-29 11:47

    No it is not compatible. I've run into the same issue and while many will say that Java 8 is completely backwards compatible with older versions of java, this turns out not to be true.

    This has a very good explaination of the exact problem I ran into java 7 targeted code with java 8.

    https://gist.github.com/AlainODea/1375759b8720a3f9f094

    Because the API of ConcurrentHashMap has changed between the 2 java releases, spring breaks on startup and you end up with

    SEVERE: Context initialization failed
    java.lang.NoSuchMethodError: java.util.concurrent.ConcurrentHashMap.keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView;
        at org.apache.catalina.core.ApplicationContext.getInitParameterNames(ApplicationContext.java:368)
        at org.apache.catalina.core.ApplicationContextFacade.getInitParameterNames(ApplicationContextFacade.java:367)
        at org.springframework.web.context.support.WebApplicationContextUtils.registerEnvironmentBeans(WebApplicationContextUtils.java:201)
        at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.postProcessBeanFactory(AbstractRefreshableWebApplicationContext.java:163)
    

    I had no choice to but upgrade to Spring 4.x (not sure if 3.2 or above would have worked as I jumped straight to 4.x)

提交回复
热议问题