Can Not Start MvvmFX java.io.IOException: Error loading FXML – can't load from given resourcepath

huangapple go评论101阅读模式
英文:

Can Not Start MvvmFX java.io.IOException: Error loading FXML - can't load from given resourcepath

问题

我正在尝试在Maven JavaFX项目中使用mvvmFX(git链接)。

这只是一个非常简单的项目,使用de.saxsys.mvvmfx.FluentViewLoader来加载一个fxml文件。

这是示例项目链接(git)示例程序

我正在使用:

  • Liberica JDK 14
  • OpenJFX 14
  • Intellij IDEA
  • Maven

> App.java

FluentViewLoader.FxmlViewStep fvs = FluentViewLoader.fxmlView( SecondView.class );
ViewTuple vt = fvs.load();
Parent parent = vt.getView();

//        Scene scene = new Scene(FluentViewLoader.fxmlView(SecondView.class).load().getView());

Scene scene = new Scene( parent );
stage.setScene(scene);
stage.show();

但我一直在收到以下错误:

Caused by: java.io.IOException: Error loading FXML - can't load from given resourcepath: /com/wiljos/SecondView.fxml
at de.saxsys.mvvmfx@1.9.0-20191021.143511-11/de.saxsys.mvvmfx.internal.viewloader.FxmlViewLoader.createFxmlLoader(FxmlViewLoader.java:285)
at de.saxsys.mvvmfx@1.9.0-20191021.143511-11/de.saxsys.mvvmfx.internal.viewloader.FxmlViewLoader.loadFxmlViewTuple(FxmlViewLoader.java:214)

看起来问题是它找不到fxml文件。有谁可以帮我解决这个问题吗?

英文:

I am tyring to use mvvmFX ( git link ) on Maven JavaFX project

It's just a very simple project to load an fxml file using de.saxsys.mvvmfx.FluentViewLoader

This is the sample project link (git) Sample Program

I am using :

  • Liberica JDK 14
  • OpenJFX 14
  • Intellij IDEA
  • Maven

> App.java

FluentViewLoader.FxmlViewStep fvs = FluentViewLoader.fxmlView( SecondView.class );
ViewTuple vt = fvs.load();
Parent parent = vt.getView();

//        Scene scene = new Scene(FluentViewLoader.fxmlView(SecondView.class).load().getView());

Scene scene = new Scene( parent );
stage.setScene(scene);
stage.show();

But i keep getting these error

Caused by: java.io.IOException: Error loading FXML - can't load from given resourcepath: /com/wiljos/SecondView.fxml
at de.saxsys.mvvmfx@1.9.0-20191021.143511-11/de.saxsys.mvvmfx.internal.viewloader.FxmlViewLoader.createFxmlLoader(FxmlViewLoader.java:285)
at de.saxsys.mvvmfx@1.9.0-20191021.143511-11/de.saxsys.mvvmfx.internal.viewloader.FxmlViewLoader.loadFxmlViewTuple(FxmlViewLoader.java:214)

Seems like the problem is, it can not find the fxml file. Can anyone help me solving this?

答案1

得分: 2

我编译并运行了这个项目。
只需将您的fxml目录打开到mvvmfx模块,类似于:

opens com.wiljos to de.saxsys.mvvmfx, javafx.fxml;

现在,mvvmfx可以正确访问fxml文件。

英文:

I compiled and ran the project.
Just open your fxml directory to module mvvmfx like:

opens com.wiljos to de.saxsys.mvvmfx,javafx.fxml;

Now the fxml file can be accessed correctly by mvvmfx.

huangapple
  • 本文由 发表于 2020年8月28日 10:23:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63626589.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定