- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 JavaFx 项目,其中 Maven install
一直给我错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project gui: Compilation failure: Compilation failure:
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[21,19] package javafx.fxml does not exist
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,17] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,45] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController
我做错了什么?我如何说服 Maven/Eclipse/Java/Whatever 找到 FXMLLoader
?
工程结构有gui
和logic
两个模块,工程结构在this tutorial .我的整体项目 pom 是:
<modules>
<module>logic</module>
<module>gui</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>11</source>
<target>11</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
gui
模块的 pom 是:
<parent>
<groupId>com.gmail.digitig</groupId>
<artifactId>gsn-notator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gui</artifactId>
<dependencies>
<dependency>
<groupId>com.gmail.digitig</groupId>
<artifactId>logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11-ea+19</version>
</dependency>
</dependencies>
我在逻辑模块中还没有任何东西,除了一个普通的 module_info.java
。报错的gui.AppController
类是:
package gui;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.BorderPane;
public class AppController extends BorderPane {
public AppController() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("App.fxml"));
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
最佳答案
您需要包含 javafx-fxml
的依赖项在你的 pom.xml
中:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.1</version>
</dependency>
并确保 module-info.java
具有用于 javafx.fxml
模块的 requires
指令。
requires javafx.fxml;
其他建议:
关于java - Maven 找不到 FXMLLoader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53357207/
尝试从 FXML 文件加载 Controller 时出现 LoadException。这是 FXML 文件:
我有主要的应用程序类,可以很好地完成以下任务: @Override public void start(Stage primaryStage) { try {
在“Pro JavaFX 8:构建桌面、移动和嵌入式 Java 客户端的权威指南”的第 3 章中,一个示例说明了如何直接在 FXML 文件中指定对象。 您可以在本文末尾找到完整的 FXML 文件以及示
在“Pro JavaFX 8:构建桌面、移动和嵌入式 Java 客户端的权威指南”的第 3 章中,一个示例说明了如何直接在 FXML 文件中指定对象。 您可以在本文末尾找到完整的 FXML 文件以及示
在学习Javafx时,我已经学习了舞台、场景和场景图(树数据结构)(分支节点、叶节点)等...所以我知道场景图的基础知识,它必须包含根节点及其子节点,并且场景类采用根节点类型的参数,所以我的问题是当我
这是我的第一个问题,所以如果我出错了,请耐心等待,但我对 FXMLLoader 有一个奇怪的问题,我无法解释自己,所以任何提示或帮助将不胜感激。 以下代码片段是我如何将文件 GraphicSettin
我有一个由根布局组成的 javaFX 界面,它是一个简单的 BorderPane。当在 rootLayout 菜单上按下按钮时,我想将两个 AnchorPane 交替设置在 rootLayout 的中
我正在寻找有关在 Swing 上下文中使用 FXML 的 JavaFX 2 的一些帮助。我使用 Scene Builder(版本:2.0-b10,变更集:48fc80a12d33)构建了一个场景,并试
我正在尝试运行本教程: http://docs.oracle.com/javafx/2/fxml_get_started/custom_control.htm 我想在 Eclipse 上运行它。我从网
我在 fxml 文件的根级别有 ScrollPane,并且有以下代码: import javafx.scene.Parent; ... parent = (Parent)fxmlLoader.load
我有一个 JavaFx 项目,其中 Maven install 一直给我错误: [ERROR] Failed to execute goal org.apache.maven.plugins:mave
我正在尝试访问加载 fxml 的窗口的 Controller 类的实例。它加载时没有错误,但是当我尝试使用打印帐户数量时 System.out.println("from NAW: "+ NAC.ne
因此,我使用 JavaFX 的 Scene Builder 工具创建了一个 FXML 界面,并尝试通过我的代码加载它。但是,我在尝试加载 FXML 文档时遇到了此错误:FXMLLoader.load
我有一个用于整个应用程序的大型资源文件,因此如果我可以仅为整个 JavaFX 场景设置它,而不是每次执行 new FXMLLoader(...) 时,那就太好了。 有办法吗? 最佳答案 据我所知,没有
我正在尝试将 FXML 文件加载到我的 javafx 应用程序中作为我的根小部件,我使用带有 java 11.04 的 Windows 8.1 和带有 Eclipse 2019 IDE 的 javaf
我尝试加载 FXML 文件 MainView.fxml 就像在其他一些项目中所做的那样。但我得到“IllegalStateException:未设置位置。”但我很确定我传递了正确的位置。您还有其他想法
我们在场景构建器的帮助下创建了几个 JavaFX View 。它们的组件通过 FXMLLoader 注入(inject)到 Controller 类中,例如 TreeTableView。现在我想重写
我正在创建一个 ListView,能够双击每个项目并弹出一个窗口,其中包含由 FXML 文件构成的输入。 FXML 文件 itemStep 包含 fx:controller="controller.I
这个问题在这里已经有了答案: What is a NullPointerException, and how do I fix it? (12 个答案) 关闭 3 年前。 我是 java 和 mvc
我一直在为我的 JavaFX 学习做一个小应用程序。在应用程序中,我需要从主文件中单独获取 Controller ,所以我设计了这个: public class DiceObserver implem
我是一名优秀的程序员,十分优秀!