遇到這個錯誤是在Apache Tomcat上部署應用程序的時候遇到的,具體的錯誤描述是:
java.lang.UnsupportedClassVersionError: HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) ...... ...... at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
主要的內容是:
has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method)
也就是當前的jre不能對程序進行編譯,這個問題其實很簡單,
Tomcat的版本和JDK的版本不對應導致的,當前我運行的jdk是1.8而我用的Tomcat版本是Tomcat 9所以就會出現這個問題。
解決方法:要么降低Tomcat的版本號,要不用JDK9,
當然我用的是前者,畢竟JDK9剛剛出來,出錯還是有可能的
ok,解決了。