【问题标题】:Java Maven assembly plugin Fatal error compiling: invalid target release 1.14Java Maven 程序集插件致命错误编译:无效的目标版本 1.14
【发布时间】:2020-07-17 11:02:04
【问题描述】:

我想使用 maven 程序集插件在 Intellij 中部署我的 javafx 项目,但每当我尝试这样做时,我都会得到

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Battlesheet: Fatal error compiling: error: invalid target release: 1.14 -> [Help 1]

结果。我的 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>

    <groupId>org.Avalon</groupId>
    <artifactId>Battlesheet</artifactId>
    <version>1.0</version>
    <name>Avalon Battlesheet</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.14</maven.compiler.source>
        <maven.compiler.target>1.14</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>15-ea+6</version>
            <classifier>win</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>15-ea+6</version>
            <classifier>mac</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>15-ea+6</version>
            <classifier>linux</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>13</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>15-ea+6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.6</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <mainClass>assembly.Launcher</mainClass>
                    <launcher>launch.sh</launcher>
                    <compress>2</compress>
                    <jlinkZipName>avalon-battlesheet</jlinkZipName>
                    <jlinkImageName>avalon-battlesheet</jlinkImageName>
                    <noManPages>true</noManPages>
                    <noHeaderFiles>true</noHeaderFiles>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>create-executable</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outputDirectory>${test.pack.dir}</outputDirectory>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>assembly.Launcher</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


我知道有很多这样的问题已经提出,但我至少阅读了其中的大部分,但无济于事。我的路径和 JAVA_HOME 都设置为我唯一的 JDK(AdoptOpenJDK 1.14),我的项目结构应该全部设置为 1.14,但现在我的知识失败了,为什么它仍然告诉我我的目标版本无效。任何帮助将不胜感激:)

【问题讨论】:

  • 尝试使用 maven-compiler 插件:mkyong.com/maven/maven-error-invalid-target-release-1-11
  • 因为1.14 确实不是一个有效的目标。在 Java 8 之后,1. 被删除。 Java 1.14 不存在。此外,无论如何,Maven 始终支持X 而不是1.X 语法。 TL;DR:14 不是 1.14

标签: java maven javafx maven-assembly-plugin


【解决方案1】:

您似乎正在尝试使用 Java 14 进行构建。不再使用前缀(又名 1.),因此请尝试将 1.14 更改为 14

【讨论】:

    猜你喜欢
    • 2015-06-14
    • 2015-10-14
    • 2020-11-19
    • 2018-08-03
    • 2015-06-01
    • 2017-10-29
    • 2022-09-26
    • 2015-04-02
    • 2021-04-10
    相关资源
    最近更新 更多