简体   繁体   English

Maven 编译器插件 不支持 class 文件主要版本 60

[英]Maven compiler plugin Unsupported class file major version 60

I am updating a Spigot (Minecraft) plugin and the newest version of Spigot requires Java 16. In my pom I changed the maven compiler plugin target to 16 and the source is still 1.8.我正在更新一个 Spigot (Minecraft) 插件,最新版本的 Spigot 需要 Java 16。在我的 pom 中,我将 maven 编译器插件目标更改为 16,而源代码仍然是 1.8。 Now I am getting the following errors:现在我收到以下错误:

Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default) on project Plugin: Error creating shaded jar: Problem shading JAR C:\Users\Trent\workspace\Stocks\Plugin\target\Plugin-1.0-SNAPSHOT.jar entry com/tchristofferson/stocks/commands/StockbrokerCommand.class: java.lang.IllegalArgumentException: Unsupported class file major version 60

pom:起居室:

<?xml version="1.0" encoding="UTF-8"?>

4.0.0 4.0.0

<groupId>com.tchristofferson</groupId>
<artifactId>Stocks</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
    <module>API</module>
    <module>Plugin</module>
</modules>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>16</target>
                <release>16</release>
            </configuration>
        </plugin>
    </plugins>
</build>

<distributionManagement>
    <snapshotRepository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
</distributionManagement>

@wemu was correct that the maven shade plugin doesn't yet support Java 16. To solve the issue I had to use a snapshot version of the maven shade plugin (3.3.0-SNAPSHOT) since 3.2.4 doesn't support Java 16 yet. @wemu was correct that the maven shade plugin doesn't yet support Java 16. To solve the issue I had to use a snapshot version of the maven shade plugin (3.3.0-SNAPSHOT) since 3.2.4 doesn't support Java 16然而。

I had to use this before I could use 3.3.0-SNAPSHOT我必须先使用它才能使用 3.3.0-SNAPSHOT

<pluginRepositories>
    <pluginRepository>
        <id>maven-snapshots</id>
        <url>https://repository.apache.org/content/repositories/snapshots/</url>
    </pluginRepository>
</pluginRepositories>

To elaborate on the answer @tchristofferson has given, I got it working by setting snapshots to true in my pluginRepository:为了详细说明@tchristofferson 给出的答案,我通过在我的 pluginRepository 中将 snapshots 设置为 true 来让它工作:

<pluginRepositories>
    <pluginRepository>
        <releases>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>central</id>
        <name>Maven Plugin Repository</name>
        <url>http://repo1.maven.org/maven2</url>
    </pluginRepository>
</pluginRepositories>

If you don't have the above in your pom.xml , just add it somewhere within <project></project> .如果您的pom.xml中没有上述内容,只需将其添加到<project></project>中的某个位置。 And then change the version of the maven-shade-plugin to this:然后将 maven-shade-plugin 的版本更改为:

<version>3.3.0-SNAPSHOT</version>

In my case, the latest version of maven was installed on my machine, and code was intended for the java 11 version.就我而言,最新版本的 maven 安装在我的机器上,代码适用于 java 11 版本。 So I have used an older version of maven and the error didn't appear.所以我使用了旧版本的 maven 并没有出现错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复tomcat9中“不支持的类文件主要版本60”? - How to fix “unsupported class file major version 60” in tomcat9? 在openjdk11下执行sonar-maven-plugin时,不支持的类文件主要版本55 - Unsupported class file major version 55 when executing sonar-maven-plugin under openjdk11 JDK-13 不受支持的 class 文件主版本 - JDK-13 Unsupported class file major version for surefire plugin Maven surefire 插件 2.22.2 构建失败,用于 Junit 5 测试用例,错误不支持 Spring Boot 中的类文件主要版本 56 - Maven surefire plugin 2.22.2 build fails for Junit 5 test cases with errror Unsupported class file major version 56 in spring boot Caused by: java.lang.IllegalArgumentException: Unsupported class 文件主要版本 60 - Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 60 如何在 IntelliJ IDEA 中修复“不支持的 class 文件主要版本 60”? - How can I fix "unsupported class file major version 60" in IntelliJ IDEA? Spark 错误 - 不支持的类文件主要版本 - Spark Error - Unsupported class file major version TomEE 8 不支持的类文件主要版本 61 - Unsupported class file major version 61 with TomEE 8 IllegalArgumentException:'不支持 class 文件主要版本 55' - IllegalArgumentException: 'Unsupported class file major version 55' 不支持 class 文件主要版本 58 - Unsupported class file major version 58
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM