这是我的项目结构:
我在Window.java类的这些行上获得java.lang.IllegalStateException: Location is not set.
。
FXMLLoader loader = new FXMLLoader(getClass().getResource("fxml/LoginWindow.fxml"));
Parent root = loader.load(); // this line is getting the error
10分钟前一切正常,但后来我将所有软件包移动到我正在使用maven的新项目中,制定了依赖项,将所有软件包重命名为与上一个项目相同,但是当我'我试图运行我得到上述错误。不知道为什么?
我的fxml文件中的代码是正确的,没有错误。这些课没有错误。
编辑:我也尝试了静态方法来加载fxml文件并得到了同样的错误。
编辑:我在pom.xml
的构建部分中添加了这个:
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
感谢@James_D的帮助!