【发布时间】:2020-04-28 01:11:37
【问题描述】:
我试图创建编译我的应用程序并创建一个可执行文件。至于现在,我认为最好的工具是 javafx-maven-plugin。
我无法让它工作,所以我从根据这个创建项目时生成的基本代码开始。
https://www.youtube.com/watch?v=4vd-RE0X5Lg
https://openjfx.io/openjfx-docs/#maven
基本示例有效,但是当我在我的代码中尝试相同的结构或简单地添加包含 jfoenix 的代码时。它无法运行。
下面的行似乎是错误的重要行,
原因:java.lang.IllegalAccessError:com.jfoenix.skins.JFXSpinnerSkin 类(com.jfoenix 模块中)无法访问 com.sun.javafx.scene.NodeHelper 类(javafx.graphics 模块中),因为模块 javafx。图形不会将 com.sun.javafx.scene 导出到模块 com.jfoenix
我该如何解决这个问题?
这是我到目前为止的 pom。
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openjfx</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>9.0.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<compilerArgs>
<arg>--add-opens</arg><arg>javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>org.openjfx.App</mainClass>
<options>
<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</option>
</options>
</configuration>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
-
您的问题不是很清楚,但是如果您需要有关 maven pom 的帮助,请告诉我。如果 JFoenix 与 JavaFX 11 及更高版本一起使用,它应该可以直接使用。让我看看有没有。
-
您需要在 jvm 参数中添加 --add-opens javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED ;有一种方法可以在 Maven 中做到这一点,我无法让它工作。让我知道它是否有效。
-
成功!我让它运行了