gpt4 book ai didi

java - 项目在 intellij 中编译,但导出时不编译

转载 作者:太空宇宙 更新时间:2023-11-04 10:22:54 25 4
gpt4 key购买 nike

因此,当我通过 intellij 运行我的应用程序时,它会正常运行和运行,但是当我导出应用程序时,它甚至不会启动。这是我得到的堆栈跟踪。

Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at application.UIController.start(UIController.java:42)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Exception running application application.UIController

Process finished with exit code 1

这是它所提示的代码。

public void start(Stage stage) {

screen = stage;

try {
FXMLLoader loader = new FXMLLoader(UIController.class.getResource("/fxml/LoginFXML.fxml"));
Parent root = loader.load();
loginController = loader.getController();

Scene scene = new Scene(root, 340, 487);
scene.getStylesheets().add(getClass().getResource("/css/application.css").toExternalForm());
screen.setScene(scene);
screen.show();
screen.setResizable(false);
screen.setTitle("Room Booking System");

if (launched.equals(false)) {
launched = true;
Database_Control launchdb = new Database_Control();
launchdb.launch();
}



Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
screen.setX((screenBounds.getWidth() - screen.getWidth()) / 2);
screen.setY((screenBounds.getHeight() - screen.getHeight()) / 2);
} catch (IOException e) {
e.printStackTrace();
}
}

它提示位置未设置,所以我尝试了

FXMLLoader loader = new FXMLLoader();   loader.setLocation(UIController.class.getResource("/fxml/LoginFXML.fxml"));

但是它一直给我带来同样的问题。提前致谢。

我的文件结构 https://gyazo.com/cec056fb358f453d32f49676bde12b5d

最佳答案

位置未设置错误意味着编译器找不到您所引用的 FXML 文件。我确实看到您的 FXML 文件是 loginFXML.fxml,但您尝试使用大写 L:LoginFXML.fxml 加载该文件。这在测试中似乎没有任何影响,但导出时可能会发生一些情况?

关于java - 项目在 intellij 中编译,但导出时不编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50898372/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com