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

浪尽此生 提交于 2020-04-06 07:18:13

问题


I have this error

How to fix it?

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

I have such 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.


回答1:


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

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



回答2:


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:

<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




回答3:


I accidentally upgraded my java before doing the:

./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


To fix this I installed the latest 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 init

move the build and settings back

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

rebuild your project



来源:https://stackoverflow.com/questions/57299672/how-to-fix-unsupported-class-file-major-version-57-in-maven-for-java-13-and-spri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!