首页 > 解决方案 > 无法在项目上执行目标 org.openjfx:javafx-maven-plugin:0.0.6:run (default-cli):错误:错误:输出目录为空 -> [帮助 1]

问题描述

我有一个非模块化 javafx 项目,想用 maven 运行它,但我没有这方面的经验。

我正在使用 IntelliJ IDEA,所以我转到根目录,右键单击 -> 添加框架支持,然后选择 maven。添加了一个 pom.xml 文件。

参考https://openjfx.io/openjfx-docs/#maven后,我将 pom.xml 文件修改为如下所示:

<?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.openjfx</groupId>
    <artifactId>AccountZeyny</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>AccountZeyny</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>11</maven.compiler.release>
        <javafx.version>15</javafx.version>
        <javafx.maven.plugin.version>0.0.6</javafx.maven.plugin.version>
    </properties>

    <organization>
        <!-- Used as the 'Vendor' for JNLP generation -->
        <name>ORGZ</name>
    </organization>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>15</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>15</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>${maven.compiler.release}</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <configuration>
                    <release>${maven.compiler.release}</release>
                    <mainClass>org.openjfx.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

我去了Maven选项卡->插件->编译器->编译器:编译。然后插件 -> javafx -> javafx:ru​​n。我在下面的运行选项卡中得到了这个:

D:\openjdk-15.0.1_windows-x64_bin\jdk-15.0.1\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\Account-Zeyny "-Dmaven.home=D:\IntelliJ IDEA Community Edition 2021.1.3\plugins\maven\lib\maven3" "-Dclassworlds.conf=D:\IntelliJ IDEA Community Edition 2021.1.3\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=D:\IntelliJ IDEA Community Edition 2021.1.3\plugins\maven\lib\maven-event-listener.jar" "-javaagent:D:\IntelliJ IDEA Community Edition 2021.1.3\lib\idea_rt.jar=64148:D:\IntelliJ IDEA Community Edition 2021.1.3\bin" -Dfile.encoding=UTF-8 -classpath "D:\IntelliJ IDEA Community Edition 2021.1.3\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;D:\IntelliJ IDEA Community Edition 2021.1.3\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version=2021.1.3 org.openjfx:javafx-maven-plugin:0.0.6:run
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< org.openjfx:AccountZeyny >----------------------
[INFO] Building AccountZeyny 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> javafx-maven-plugin:0.0.6:run (default-cli) > process-classes @ AccountZeyny >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ AccountZeyny ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Account-Zeyny\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ AccountZeyny ---
[INFO] No sources to compile
[INFO] 
[INFO] <<< javafx-maven-plugin:0.0.6:run (default-cli) < process-classes @ AccountZeyny <<<
[INFO] 
[INFO] 
[INFO] --- javafx-maven-plugin:0.0.6:run (default-cli) @ AccountZeyny ---
[INFO] Toolchain in javafx-maven-plugin null
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  25.189 s
[INFO] Finished at: 2021-07-15T18:02:32+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.6:run (default-cli) on project AccountZeyny: Error: Error: Output directory is empty -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Process finished with exit code 1

我在这些步骤中犯了错误吗?

编辑:我正在使用 IntelliJ IDEA 2021.1.3 x64。

标签: mavenintellij-ideajavafx

解决方案


推荐阅读