1:獲取resource目錄:
LibXIStream.class.getClass().getResource("/").getPath()
2:獲取resource目錄下的檔案輸入流:
GlobalUtils.class.getResourceAsStream("/dll/" + fileName);
3:resource目錄不編譯導致無法讀取檔案:
在pom.xml檔案中加入以下內容即可
<build> <resources> <resource> <directory>src/main/resource</directory> <includes> <include>config/*</include> <include>dll/*</include> </includes> <filtering>true</filtering> </resource> </resources> </build>