zoukankan      html  css  js  c++  java
  • Unsupported major.minor version 52.0 (unable to load class XXX

    java项目构建从高版本JDK改为低版本JDK报错。这是再次编译时使用的JDK版本比你原来编译的版本低所导致的。 
    转自:http://blog.csdn.net/zixiao217 
    maven项目在服务器上构建时报错(Unsupported major.minor version 52.0 ): 
    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.ExecutorsDeployWar.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)

    原来本地项目指定的JDK版本是1.8的:

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
    </plugin>

    部署到linux服务器上之后,启动项目时报Unsupported major.minor version 52.0 错误,检查发现是linux服务器上JDK版本过低导致的,然后将项目指定JDK版本为1.7,再发布启动OK了。

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
    </plugin>

    JDK版本在官方对应的版本号列表如下:

    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

  • 相关阅读:
    angular2监听页面大小变化
    angular如何引入公共JS
    angular使用Md5加密
    angular4模块中标签添加背景图
    angular使用sass的scss语法
    设置angular公共样式表
    更改angular的默认端口
    angular模拟web API
    RN与webview通讯
    shell通过ping检测整个网段IP的网络状态脚本
  • 原文地址:https://www.cnblogs.com/sharpest/p/8618955.html
Copyright © 2011-2022 走看看