java

关注公众号 jb51net

关闭
首页 > 软件编程 > java > SpringBoot启动异常

SpringBoot启动异常Exception in thread “main“ java.lang.UnsupportedClassVersionError

作者:棒棒糖的糖不含糖

本文主要介绍了SpringBoot启动异常Exception in thread “main“ java.lang.UnsupportedClassVersionError,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

异常提示:Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/SpringApplication has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

 一、完整错误报文(两种)

1.1 启动异常之UnsupportedClassVersionError

Exception in thread "main" java.lang.UnsupportedClassVersionError: 
org/springframework/boot/SpringApplication has been compiled by a 
more recent version of the Java Runtime (class file version 61.0), 
this version of the Java Runtime only recognizes class file 
versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.handlefile.Application.main(Application.java:10)

1.2 启动异常之启动类无法访问

Error:(3, 32) java: 无法访问org.springframework.boot.SpringApplication
  错误的类文件: /E:/ideaMaven/repMaven/org/springframework/boot/spring-boot/
3.0.1/spring-boot-3.0.1.jar!/org/springframework/boot/SpringApplication.class
    类文件具有错误的版本 61.0, 应为 52.0
    请删除该文件或确保该文件位于正确的类路径子目录中。

二、错误原因 

 SpringBoot 与 JDK 版本冲突:新建项目时,idea 会默认选择更高的 SpringBoot 版本,但>3.0SpringBoot 的版本暂不支持 JDK1.8,所以会出现启动报错

一般来说高JDK版本能向下兼容低版本的springboot版本。

建议在springboot 2.5.x及其之前使用JDK8,之后的springboot版本使用JDK11即可

三、解决方案

在pom.xml文件中修改SpringBoot版本或JDK版本

四、简要介绍SpringBoot版本与JDK版本对应关系

SpringBoot版本JDK最低版本SpringBoot官网证据
1.0.0.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.0.1.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.0.2.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.0.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.1.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.2.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.3.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.4.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.5.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.6.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.7.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.8.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.9.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.10.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.11.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.1.12.RELEASE1.6Regardless, you will need Java SDK v1.6 or higher.
1.2.0.RELEASE1.6Spring Boot 1.2.0.RELEASE requires Java 6 and Spring Framework 4.1.3 or above.
1.2.1.RELEASE1.6Spring Boot 1.2.1.RELEASE requires Java 6 and Spring Framework 4.1.3 or above.
1.2.2.RELEASE1.7Spring Boot 1.2.2.RELEASE requires Java 7 and Spring Framework 4.1.3 or above.
1.2.3.RELEASE1.7Spring Boot 1.2.3.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.
1.2.4.RELEASE1.7Spring Boot 1.2.4.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.
1.2.5.RELEASE1.7Spring Boot 1.2.5.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.
1.2.6.RELEASE1.7Spring Boot 1.2.6.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.
1.2.7.RELEASE1.7Spring Boot 1.2.7.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.
1.2.8.RELEASE1.7Spring Boot 1.2.8.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.
1.3.0.RELEASE1.7Spring Boot 1.3.0.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.
1.3.1.RELEASE1.7Spring Boot 1.3.0.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.
1.3.2.RELEASE1.7

Spring Boot 1.3.0.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.

1.3.3.RELEASE1.7Spring Boot 1.3.0.RELEASE requires Java 7 and Spring Framework 4.1.5 or above.

1.3.4.RELEASE

1.7

Spring Boot 1.3.4.RELEASE requires Java 7 and Spring Framework 4.2.6.RELEASE or above.

1.3.5.RELEASE1.7Spring Boot 1.3.5.RELEASE requires Java 7 and Spring Framework 4.2.6.RELEASE or above.
1.3.6.RELEASE1.7Spring Boot 1.3.6.RELEASE requires Java 7 and Spring Framework 4.2.7.RELEASE or above.
1.3.7.RELEASE1.7Spring Boot 1.3.7.RELEASE requires Java 7 and Spring Framework 4.2.7.RELEASE or above.
1.3.8.RELEASE1.7Spring Boot 1.3.8.RELEASE requires Java 7 and Spring Framework 4.2.8.RELEASE or above.
1.4.0.RELEASE1.7Spring Boot 1.4.0.RELEASE requires Java 7 and Spring Framework 4.3.2.RELEASE or above.
1.4.1.RELEASE1.7Spring Boot 1.4.1.RELEASE requires Java 7 and Spring Framework 4.3.3.RELEASE or above.
1.4.2.RELEASE1.7Spring Boot 1.4.2.RELEASE requires Java 7 and Spring Framework 4.3.4.RELEASE or above.
1.4.3.RELEASE1.7Spring Boot 1.4.3.RELEASE requires Java 7 and Spring Framework 4.3.5.RELEASE or above.
1.4.4.RELEASE1.7Spring Boot 1.4.4.RELEASE requires Java 7 and Spring Framework 4.3.6.RELEASE or above.
1.4.5.RELEASE1.7Spring Boot 1.4.5.RELEASE requires Java 7 and Spring Framework 4.3.7.RELEASE or above.
1.4.6.RELEASE1.7Spring Boot 1.4.6.RELEASE requires Java 7 and Spring Framework 4.3.8.RELEASE or above.
1.4.7.RELEASE1.7Spring Boot 1.4.7.RELEASE requires Java 7 and Spring Framework 4.3.9.RELEASE or above.
1.5.0.RELEASE1.7Spring Boot 1.5.0.RELEASE requires Java 7 and Spring Framework 4.3.6.RELEASE or above.
1.5.1.RELEASE1.7Spring Boot 1.5.1.RELEASE requires Java 7 and Spring Framework 4.3.6.RELEASE or above.
1.5.2.RELEASE1.7Spring Boot 1.5.2.RELEASE requires Java 7 and Spring Framework 4.3.7.RELEASE or above.
1.5.3.RELEASE1.7Spring Boot 1.5.3.RELEASE requires Java 7 and Spring Framework 4.3.8.RELEASE or above.
1.5.4.RELEASE1.7Spring Boot 1.5.4.RELEASE requires Java 7 and Spring Framework 4.3.9.RELEASE or above.
1.5.5.RELEASE1.7Spring Boot 1.5.5.RELEASE requires Java 7 and Spring Framework 4.3.10.RELEASE or above.
1.5.6.RELEASE1.7Spring Boot 1.5.6.RELEASE requires Java 7 and Spring Framework 4.3.10.RELEASE or above.
1.5.7.RELEASE1.7Spring Boot 1.5.7.RELEASE requires Java 7 and Spring Framework 4.3.11.RELEASE or above.
1.5.8.RELEASE1.7Spring Boot 1.5.8.RELEASE requires Java 7 and Spring Framework 4.3.12.RELEASE or above.
1.5.9.RELEASE1.7Spring Boot 1.5.9.RELEASE requires Java 7 and Spring Framework 4.3.13.RELEASE or above.
1.5.10.RELEASE1.7Spring Boot 1.5.10.RELEASE requires Java 7 and Spring Framework 4.3.14.RELEASE or above.
1.5.11.RELEASE1.7Spring Boot 1.5.11.RELEASE requires Java 7 and Spring Framework 4.3.15.RELEASE or above.
1.5.12.RELEASE1.7Spring Boot 1.5.12.RELEASE requires Java 7 and Spring Framework 4.3.16.RELEASE or above.
1.5.13.RELEASE1.7Spring Boot 1.5.13.RELEASE requires Java 7 and Spring Framework 4.3.17.RELEASE or above.
1.5.14.RELEASE1.7Spring Boot 1.5.14.RELEASE requires Java 7 and Spring Framework 4.3.18.RELEASE or above.
1.5.15.RELEASE1.7Spring Boot 1.5.15.RELEASE requires Java 7 and Spring Framework 4.3.18.RELEASE or above.
1.5.16.RELEASE1.7Spring Boot 1.5.16.RELEASE requires Java 7 and Spring Framework 4.3.19.RELEASE or above.
1.5.17.RELEASE1.7Spring Boot 1.5.17.RELEASE requires Java 7 and Spring Framework 4.3.20.RELEASE or above.
1.5.18.RELEASE1.7Spring Boot 1.5.18.RELEASE requires Java 7 and Spring Framework 4.3.21.RELEASE or above.
1.5.19.RELEASE1.7Spring Boot 1.5.19.RELEASE requires Java 7 and Spring Framework 4.3.22.RELEASE or above.
1.5.20.RELEASE1.7Spring Boot 1.5.20.RELEASE requires Java 7 and Spring Framework 4.3.23.RELEASE or above.
1.5.21.RELEASE1.7Spring Boot 1.5.21.RELEASE requires Java 7 and Spring Framework 4.3.24.RELEASE or above.
2.0.0.RELEASE1.8Spring Boot 2.0.0.RELEASE requires Java 8 or 9 and Spring Framework 5.0.4.RELEASE or above.
2.0.1.RELEASE1.8Spring Boot 2.0.1.RELEASE requires Java 8 or 9 and Spring Framework 5.0.5.RELEASE or above.
2.0.2.RELEASE1.8Spring Boot 2.0.2.RELEASE requires Java 8 or 9 and Spring Framework 5.0.6.RELEASE or above.
2.0.3.RELEASE1.8Spring Boot 2.0.3.RELEASE requires Java 8 or 9 and Spring Framework 5.0.7.RELEASE or above.
2.0.4.RELEASE1.8Spring Boot 2.0.4.RELEASE requires Java 8 or 9 and Spring Framework 5.0.8.RELEASE or above.
2.0.5.RELEASE1.8Spring Boot 2.0.5.RELEASE requires Java 8 or 9 and Spring Framework 5.0.9.RELEASE or above.
2.0.6.RELEASE1.8Spring Boot 2.0.6.RELEASE requires Java 8 or 9 and Spring Framework 5.0.10.RELEASE or above.
2.0.7.RELEASE1.8Spring Boot 2.0.7.RELEASE requires Java 8 or 9 and Spring Framework 5.0.11.RELEASE or above.
2.0.8.RELEASE1.8Spring Boot 2.0.8.RELEASE requires Java 8 or 9 and Spring Framework 5.0.12.RELEASE or above.
2.0.9.RELEASE1.8Spring Boot 2.0.9.RELEASE requires Java 8 or 9 and Spring Framework 5.0.13.RELEASE or above.
2.1.0.RELEASE1.8Spring Boot 2.1.0.RELEASE requires Java 8 or 9 and Spring Framework 5.1.2.RELEASE or above.
2.1.1.RELEASE1.8Spring Boot 2.1.1.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.3.RELEASE or above is also required.
2.1.2.RELEASE1.8Spring Boot 2.1.2.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.4.RELEASE or above is also required.
2.1.3.RELEASE1.8Spring Boot 2.1.3.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.5.RELEASE or above is also required.
2.1.4.RELEASE1.8Spring Boot 2.1.4.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.6.RELEASE or above is also required.
2.1.5.RELEASE1.8Spring Boot 2.1.5.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.7.RELEASE or above is also required.
2.1.6.RELEASE1.8Spring Boot 2.1.6.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.8.RELEASE or above is also required.
未完,待续...

 到此这篇关于SpringBoot启动异常Exception in thread “main“ java.lang.UnsupportedClassVersionError的文章就介绍到这了,更多相关SpringBoot启动异常内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文