pom.xml
主要设置pom文件
<build>
<resources>
<resource>
<!--将fxml文件放在src/main/resources-->
<!--fxml文件放在那里就写那里的路径,路径不对就找不到fxml文件-->
<directory>src/main/resources</directory>
<includes>
<!--需要显示的资源需要在这里设置过滤-->
<include>**/*.properties</include>
<include>**/*.fxml</include>
<include>**/fxml/*.fxml</include>
<include>**/css/*.css</include>
<include>**/file/*.png</include>
<include>**/file/*.jpg</include>
<!-- 如果想要弄个包名专门放fxml文件,像上一行这样添加设置 -->
<!-- 之后,使用getResource("fxml/xx.fxml")这样子 -->
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
基本就是这个样子。
参考文章
https://www.cnblogs.com/stars-one/p/10959869.html