【发布时间】:2012-03-07 04:09:48
【问题描述】:
将 maven 项目构建到 jar 中后,我得到 FileNotFoundException。我知道资源文件在项目构建后位于根目录中,因此我使用它来获取我的文件:
final File file = new File("maps/ParcelsCountyRDMFinal5.shp");
这是一个例外:
C:\Users\ilija\Desktop\MavenizedCP\cp-map\target>java -jar cp-map-0.0.1-SNAPSHOT
-shaded.jar
Exception in thread "main" java.io.FileNotFoundException: C:\Users\ilija\Desktop
\MavenizedCP\cp-map\target\maps\ParcelsCountyRDMFinal5.shp (The system cannot fi
nd the path specified)
这里的工作目录显然是我要运行jar的目录。我想工作目录应该是 jar 的根目录。
请在这里帮忙。我究竟做错了什么?
【问题讨论】:
-
您的 ParcelsCountyRDMFinal5.shp 文件到底在哪里?它在 C:\maps\ParcelsCountyRDMFinal5.shp 中还是在资源目录中的 maven 项目中?
-
它是我的 maven 项目资源目录的一部分!