java - Intellij Idea 构建的 jar 不包含 /src 目录
问题描述
我已经用 Intellij IDEA 构建了我的 jar 文件。在我的代码中的某处,我的 fxml 文件有这个静态动态文件路径:
private static URL fxmlResourcePath2 =
new URL("file://" + System.getProperty("user.dir")
+ File.separator
+ "src"
+ File.separator
+ "dev"
+ File.separator
+ "folling"
+ File.separator
+ "resources"
+ File.separator
+ "fxml"
+ File.separator
)
注意我还尝试了许多其他版本,例如
private static URL fxmlResourcePath =
new URL("file://" + new File(
"src${File.separator}"+
"dev${File.separator}" +
"folling${File.separator}" +
"resources${File.separator}" +
"fxml${File.separator}").absolutePath + File.separator
)
现在,这与我当前的项目结构完美配合
虽然一旦我构建了 jar,/src
目录就会消失,jar tf thejarofsubject.jar > output.txt
在快速搜索“src”后没有任何结果。解压 jar 会发现它立即从/dev
目录开始。我不能只从我的动态路径中删除“src”,否则它不会在我的 IDE 中运行,但我也不能只保留它,因为在这种情况下它不能在 IDE 之外工作。我究竟做错了什么?
解决方案
推荐阅读
- excel - 包含偏移量的 VBA 命名范围在图表中是固定的
- sql-server - 用于运行 SSIS 包的裸机设置
- javascript - 如何在 Google AppScript 中使用 sheet-js git 库?
- ksh - ksh 源文件:无法打开 [没有这样的文件或目录]
- android - 本地 onclicklistener 这样做会导致内存泄漏吗
- uber-api - 对于 Uber 开发 API,是否可以将源地址和目标地址作为参数传递以获取成本估算响应
- php - 如何将数组存储为属性中的字符串
- sql - 使用来自其他字段的 SUM 进行 SQL 更新
- tfs - 需要签署用户模式驱动程序但找不到匹配的交叉证书 - Windows 和 TFS 构建
- javascript - 功能 onclick javascript 在 Microsoft Edge 中不起作用