如何在 Java 13 和 Spring 的 Maven 中修复不受支持的类文件主要版本 57

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/57299672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 01:18:32  来源:igfitidea点击:

How to fix Unsupported class file major version 57 in maven for Java 13 and Spring

javamavenbuildcompiler-errors

提问by Arthur

I have this error

我有这个错误

How to fix it?

如何解决?

Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 57

I have such POM

我有这样的 POM

 <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
</parent>

<properties>
    <java.version>13</java.version>
</properties>

Project has many literals, so Java 13 is required.

项目有很多文字,因此需要 Java 13。

采纳答案by Jayaprada Gopalakrishna

Changing Spring boot version in the pom.xml solved this issue for me.

在 pom.xml 中更改 Spring boot 版本为我解决了这个问题。

   <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.0.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
   </parent>

回答by Erwin Bolwidt

The 2.2.0 version of spring-boot hasn't been released yet, but there is a milestone build (M4). If you want to use it, you need to add another maven repository to your pom.xml file:

spring-boot 2.2.0 版本还没有发布,但是有一个里程碑版本(M4)。如果你想使用它,你需要在你的 pom.xml 文件中添加另一个 maven 仓库:

<repositories>
    <repository> 
        <id>repository.spring.milestone</id> 
        <name>Spring Milestone Repository</name> 
        <url>http://repo.spring.io/milestone</url> 
    </repository>
</repositories>

You can then depend on the milestone build:

然后,您可以依赖里程碑构建:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.0.M4</version>
</parent>

See also: https://www.baeldung.com/spring-maven-repository

另见:https: //www.baeldung.com/spring-maven-repository

回答by Jordan Shaw

I accidentally upgraded my java before doing the:

在执行以下操作之前,我不小心升级了我的 java:

./gradlew wrapper --gradle-version 6.2.2 --debug --stacktrace

This is the only surefire way I was able to upgrade to jdk13 and gradle 6.2.2. There might be a simpler less destructive way but this worked for me

这是我能够升级到 jdk13 和 gradle 6.2.2 的唯一可靠方法。可能有一种更简单的破坏性较小的方法,但这对我有用



To fix this I installed the latest gradle

为了解决这个问题,我安装了最新的 gradle

brew install gradle

From root of project, move the existing build and settings to temp location

从项目的根目录,将现有的构建和设置移动到临时位置

mv build.gradle build.gradle.old
mv settings.gradle settings.gradle.old

re init the gradle application and follow prompts

重新初始化 gradle 应用程序并按照提示操作

gradle init

move the build and settings back

将构建和设置移回

mv build.gradle.old build.gradle
mv settings.gradle.old settings.gradle

rebuild your project

重建你的项目