繁体   English   中英

带有 maven 和 IntelliJ 的 OpenJFX 14:无法运行应用程序

[英]OpenJFX 14 with maven and IntelliJ : Cannot run application

我正在尝试在 IntelliJ 上的 JDK 14 Java 项目上使用 OpenJFX。 我的项目有多个 IntelliJ 模块,每个模块都有一个 pom.xml。

在包含我的主要模块的 IntelliJ 模块中,我添加了 JFX 作为依赖项:

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>14</version>
    <type>pom</type>
</dependency>

在我的顶级 pom.xml 我添加了 JFX 插件:

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.4</version>
    <configuration>
        <mainClass>fr.efrei.wiemetarsene.caspersky.app.Main</mainClass>
    </configuration>
</plugin>

但是当我尝试运行我的应用程序时:

mvn javafx:run

我得到以下错误:

[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:run (default-cli) on project caspersky: Error: Output directory is empty, compile first -> [Help 1]

我试图运行:

mvn compiler:compile

在这样做之前,但结果是完全一样的。 你知道为什么它不起作用吗?

我有多模块 javafx 项目,我遇到了同样的错误。 主要的 class 在我的视图模块中。 在 pom 文件中,我有:

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.5</version>
    <configuration>
        <source>14</source>
        <target>14</target>
        <release>14</release>
        <mainClass>Main</mainClass>
    </configuration>
</plugin>

然后在终端类型中:

mvn install
cd View
mvn javafx:run

在对我的代码进行一些更改后,我经常会收到一些奇怪的错误,比如缺少组件。 然后重复上述步骤即可解决问题。

从那里README ,您可以尝试以下更改:

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.4</version>
    <configuration>
        <source>14</source>
        <target>14</target>
        <release>14</release>
        <mainClass>fr.efrei.wiemetarsene.caspersky.app.Main</mainClass>
    </configuration>
</plugin>

并进一步,编译你的项目使用

mvn javafx:compile

但由于文档可能已过时,您可以尝试执行

mvn compile

或者

mvn clean javafx:jlink

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM