jar文件

时间:2017-07-13 19:07:21

标签: java spring filenotfoundexception

我正在使用nohup命令从命令行运行后台Spring服务。

我遇到以下错误:

java.io.FileNotFoundException: class path resource [templates/] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/Users/gestes/Documents/workspace/bge/bge-proj/myProcess/target/myProcess-0.2.2.jar!/templates/

正在创建jar文件并且确实存在于:

/Users/gestes/Documents/workspace/bge/bge-proj/myProcess/target/myProcess-0.2.2.jar

当我提取jar文件内容时,有一个/ templates /目录。

查看异常,有一个“! “在jar文件名之后,我认为它告诉了它找不到的东西,但很清楚,它就在那里。

我错过了什么?

1 个答案:

答案 0 :(得分:0)

如果您在代码中尝试使用java File访问该文件夹,则无法执行此操作。您需要使用inputStream

这是因为Jar中的内容实际上并不是磁盘上的文件。它们是在jar中编译的。是的,当你提取jar时它可能就在那里,但是当捆绑jar时它实际上并不是普通的磁盘文件

相关问题