簡體   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