应用程序启动方法中的java JavaFX异常
继Javafx and Intellij : Non-modular with maven之后,我在项目开始时面临一个问题
[INFO] --- javafx-maven-plugin:0.0.1:run (default-cli) @ diamond.server ---
Exception in Application start method
Exception in Application stop method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javafx.fxml.LoadException:
/C:/Users/Julien/Documents/Project/diamond.server/diamond.server/target/classes/ctrl/partiesManagement.fxml:21
我不明白是什么导致了这个问题,我找不到它,对我来说一切似乎都很好
public static void main(String[] args) {
launch();
}
static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(Ctrl.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}
@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("partiesManagement"));
stage.setScene(scene);
stage.show();
refWrk.startServer(PORT);
}
这是我的部门管理。fxml,其中链接到Java类CtrlParties
<VBox alignment="CENTER"
maxHeight="-Infinity"
maxWidth="-Infinity"
minHeight="-Infinity"
minWidth="-Infinity"
prefHeight="400.0"
prefWidth="600.0"
spacing="10.0"
**xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1"**
fx:controller="ctrl.CtrlParties">
上面的强线在构建之后是红色的。我不知道为什么
# 1 楼答案
这可能是因为IntelliJ缺少一个插件吗?我想我也有类似的例外,发现我在IDE中缺少这个插件