springboot打包成jar后获取classpath下文件失败

cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/home/ys/krt-web-1.0-SNAPSHOT.jar!/BOOT-INF/lib/krt-plugins-fastdfs-1.0-SNAPSHOT.jar!/fastdfs-client.properties

 

代码如下

这是因为打包后Spring试图访问文件系统路径,但无法访问JAR中的路径。 
因此必须使用resource.getInputStream()

 

springboot 作者回答

https://stackoverflow.com/questions/25869428/classpath-resource-not-found-when-running-as-jar

 

 

你可能感兴趣的:(springboot)