將maven項目構建到jar之後,我得到FileNotFoundException。我知道,資源文件都在根目錄下的項目被從而建立後,我用它來得到我的文件:構建jar之後的Maven資源文件
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項目的一部分? – eigil 2012-02-15 19:44:06
它是我的maven項目資源目錄的一部分! – ilija 2012-02-15 19:49:40