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

tch*_*son 2 java compiler-errors maven-plugin maven

我正在更新 Spigot (Minecraft) 插件,最新版本的 Spigot 需要 Java 16。在我的 pom 中,我将 maven 编译器插件目标更改为 16,源代码仍然是 1.8。现在我收到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

pom:

<?xml version="1.0" encoding="UTF-8"?>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

Roc*_*ogo 8

在使用 3.3.0-SNAPSHOT 之前我必须先使用它

<pluginRepositories>
    <pluginRepository>
        <id>maven-snapshots</id>
        <url>https://repository.apache.org/content/repositories/snapshots/</url>
    </pluginRepository>
</pluginRepositories>
Run Code Online (Sandbox Code Playgroud)


tch*_*son 7

@wemu 是正确的,Maven Shade 插件尚不支持 Java 16。为了解决这个问题,我必须使用 Maven Shade 插件的快照版本 (3.3.0-SNAPSHOT),因为 3.2.4 不支持 Java 16然而。