gpt4 book ai didi

jar - 在执行jar期间发生UnsupportedClassVersionError

转载 作者:行者123 更新时间:2023-12-02 10:55:58 27 4
gpt4 key购买 nike

我尝试通过使用默认的Spring Boot插件将项目打包到jar中。那是我的构建标记看起来像-仍然很简单。

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
如预期的那样,我在目标文件夹中接收到我的.jar(执行mvn安装)。但是,当我尝试执行jar
java -jar <filename>.jar
问题问题,这里是stacktrace
> C:\Users\Misha\IdeaProjects\discoveery-service\target>java -jar discoveery-service-0.0.1-SNAPSHOT.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/example/discoveeryservice/DiscoveryServiceApplication has been compiled by a more recent version of the Java Runtime (class file version 55.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(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

W
那是帽子吗?我还没有遇到这个问题。

最佳答案

解决它-我唯一改变的是java maven的版本将从11打包到8

<properties>
<java.version>8</java.version>
</properties>

关于jar - 在执行jar期间发生UnsupportedClassVersionError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64022103/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com