【已解决】this version of the Java Runtime only recognizes class file versions up to 52.0

阅读: 评论:0

【已解决】this version of the Java Runtime only recognizes class file versions up to 52.0

【已解决】this version of the Java Runtime only recognizes class file versions up to 52.0

1 报错问题

在把springboot项目打包了jar之后,准备本地运行一下

java -jar xxx-0.0.1-SNAPSHOT.jar

然后报错:

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/example/myweb/xxxApplication 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

2 可能的原因

  1. 编译版本和运行版本不一致,可能是编译版本高于运行版本导致的

修改l, 将此版本改为java -version版本

    <properties><java.version>11</java.version></properties>
  1. 为spring-boot-maven-plugin增加<parent>的版本号

如果没指定spring-boot-maven-plugin 的版本,就会拿取最新的版本打包,但是目前高版本的为未必适合1.8的jdk,如果它确实是您想要用于 spring boot 项目的版本。

为了解决这个问题,就必须明确指定spring-boot-maven-plugin的版本。

    <plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.7.9</version> //增加<parent>的版本号</plugin>

3 重新打包,运行

两种方式都尝试了一下,可以运行了!

如果运行遇到端口被占用的问题

  1. 输入netstat -lnp命令查看端口信息

  1. 使用sudo kill xxx进行删除


参考链接:

this version of the Java Runtime only recognizes class file versions up to 55.0 at ...

Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file

本文发布于:2024-01-27 10:30:43,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/17063226411176.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:Runtime   recognizes   version   Java   versions
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23