Unsupported major.minor version 51.0

今天跑spring boot的时候报了个奇怪的错误。

 

java.lang.UnsupportedClassVersionError: javax/annotation/ManagedBean : Unsupported major.minor version 51.0
 at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.6.0_14]
 at java.lang.ClassLoader.defineClass(ClassLoader.java:621) ~[na:1.6.0_14]
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) ~[na:1.6.0_14]
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) ~[na:1.6.0_14]
 at java.net.URLClassLoader.access$000(URLClassLoader.java:56) ~[na:1.6.0_14]
 at java.net.URLClassLoader$1.run(URLClassLoader.java:195) ~[na:1.6.0_14]
 at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_14]
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188) ~[na:1.6.0_14]
 at java.lang.ClassLoader.loadClass(ClassLoader.java:307) ~[na:1.6.0_14]
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) ~[na:1.6.0_14]
 at java.lang.ClassLoader.loadClass(ClassLoader.java:252) ~[na:1.6.0_14]


网上查找了下说是jdk版本不兼容的问题,改成1.6就好,然后把jdk compiler

Unsupported major.minor version 51.0_第1张图片

 

Build Path

 

Unsupported major.minor version 51.0_第2张图片

Run Configurations都换成了1.6

Unsupported major.minor version 51.0_第3张图片

跑的时候还是报一样的错误。

最后想到报错的地方

javax/annotation/ManagedBean

不是自己编译的类,是  tomcat-embed-core-8.0.30.jar 里面的,那就好办了,查看了一下这个jar包是由什么jdk编译的。直接用解压工具打开jar包,打开里面的META-INF文件夹。打开MANIFEST.MF文件。

 

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.6
Created-By: 1.7.0_80-b15 (Oracle Corporation)
Specification-Title: Apache Tomcat
Specification-Version: 8.0
Specification-Vendor: Apache Software Foundation
Implementation-Title: Apache Tomcat
Implementation-Version: 8.0.30
Implementation-Vendor: Apache Software Foundation
X-Compile-Source-JDK: 1.7
X-Compile-Target-JDK: 1.7

 

可以看出是jdk7编译的,下个1.7版本的jdk就OK了。下载地址:http://download.csdn.net/detail/fhhffchffy/9370455

其实从报错那里也是可以看出是由什么jdk版本编译的。

各JDK版本对应的错误编号如下:

J2SE 8 = 52,

J2SE 7 = 51,

J2SE 6.0 = 50,

J2SE 5.0 = 49,

JDK 1.4 = 48,

JDK 1.3 = 47,

JDK 1.2 = 46,

JDK 1.1 = 45

 

 

 

 

 

你可能感兴趣的:(Unsupported major.minor version 51.0)