java項目構建從高版本JDK改成低版本JDK報錯。這是再次編譯時使用的JDK版本比你原來編譯的版本低所致使的。maven項目在服務器上構建時報錯(Unsupported major.minor version 52.0 ):java
java.lang.UnsupportedClassVersionError: com/byron4j/listener/InitListener : Unsupported major.minor version 52.0 (unable to load class com.byron4j.listener.InitListener) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2961) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:506) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:488) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:115) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4932) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095) at org.apache.catalina.startup.HostConfigDeployWar.run(HostConfig.java:1930)atjava.util.concurrent.ExecutorsRunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)
部署到linux服務器上以後,啓動項目時報Unsupported major.minor version 52.0 錯誤,檢查發現是linux服務器上JDK版本太低致使的,而後將項目指定JDK版本爲1.7,再發布啓動OK了。linux
JDK版本在官方對應的版本號列表以下:apache
JDK 8.0 = 52, JDK 7.0 = 51, JDK 6.0 = 50, JDK 5.0 = 49, JDK 1.4 = 48, JDK 1.3 = 47, JDK 1.2 = 46, JDK 1.1 = 45
正是指定的JDK版本爲52,可是因爲服務器是JDK 7致使引起Unsupported major.minor version 52.0服務器