在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);
}
这是我的partysManagement.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">
上面的那些粗线在构建后变为红色。我不知道为什么...
答案 0 :(得分:0)
这可能是因为缺少IntelliJ插件吗?我想我也有类似的例外,发现我在IDE中缺少此插件。