gpt4 book ai didi

java - UnsupportedClassVersionError : has been compiled by a more recent version of the Java Runtime (class file version 55. 0),此版本 (..) 最高为 52.0

转载 作者:行者123 更新时间:2023-12-02 05:25:29 25 4
gpt4 key购买 nike

我正在尝试启动为 Spring Boot 项目构建的 jar 文件。首先我做了:

mvn clean package spring-boot:repackage

然后我尝试启动 jar 文件,但出现以下错误:

Exception in thread "main" java.lang.UnsupportedClassVersionError: it/sysdata/helios_backend_admin/HeliosAdminBackendApplication 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:93) at java.lang.ClassLoader.loadClass(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

我已经检查过,所有地方的 java 版本都是 11(至少从我所看到的)。这是 pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>it.sysdata</groupId>
<artifactId>helios_backend_admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>helios-admin-backend</name>
<packaging>jar</packaging>
<description>Helios Backend for Dashboard admin</description>

<properties>
<java.version>11</java.version>
<flowable.version>6.4.1</flowable.version>
<swagger.version>2.9.2</swagger.version>
<jwt.version>0.9.1</jwt.version>
<cron4j.version>2.2.5</cron4j.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>


<!-- Flowable -->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-process</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-http</artifactId>
<version>${flowable.version}</version>
</dependency>
<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jwt.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>



<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.10.1</version>
</dependency>

<dependency>
<groupId>it.sauronsoftware.cron4j</groupId>
<artifactId>cron4j</artifactId>
<version>${cron4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

这些是我在项目属性 -> Java 编译器 -> JDK 合规性下的设置:

enter image description here

然后在窗口->首选项->安装的JRE中:

enter image description here

更新

这些设置可以吗? enter image description here

最佳答案

就我而言,JAVA_HOME 设置错误,
对我来说,执行了以下步骤:

  1. Go to Environment Variables
  2. Click Edit when JAVA_HOME is selected
  3. Select the directory where your desired jdk is instaled

这可能有助于选择正确的 Java 版本:

  • Java 1.2 使用主要版本 46
  • Java 1.3 使用主要版本 47
  • Java 1.4 使用主要版本 48
  • Java 5 使用主要版本 49
  • Java 6 使用主要版本 50
  • Java 7 使用主要版本 51
  • Java 8 使用主要版本 52
  • Java 9 使用主要版本 53
  • Java 10 使用主要版本 54
  • Java 11 使用主要版本 55
  • Java 12 使用主要版本 56
  • Java 13 使用主要版本 57
  • Java 14 使用主要版本 58
  • Java 15 使用主要版本 59
  • Java 16 使用主要版本 60
  • Java 17 使用主要版本 61
  • Java 18 使用主要版本 62
  • Java 19 使用主要版本 63

关于java - UnsupportedClassVersionError : has been compiled by a more recent version of the Java Runtime (class file version 55. 0),此版本 (..) 最高为 52.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56235517/

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