应用程序启动方法中的JavaFX异常

问题描述 投票:1回答:3

跟随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">
java fxml
3个回答
0
投票

这可能是因为缺少IntelliJ的插件吗?我想我也有类似的异常,发现我在IDE中缺少此插件


0
投票

的确,根据@mmraj的回答。建立后,我的partysManagement.fxml存在问题。

  xmlns="http://javafx.com/javafx/9.0.1"
  xmlns:fx="http://javafx.com/fxml/1"

那些线红色,但我不明白为什么...


0
投票

任何主意吗?仍然找不到。...

© www.soinside.com 2019 - 2024. All rights reserved.