首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何确定fatjar的资源?

如何确定fatjar的资源?
EN

Stack Overflow用户
提问于 2018-04-03 20:20:12
回答 1查看 481关注 0票数 1

我用https://github.com/sbt/sbt-assembly构建我的scala项目,以获得一个fatjar。

项目的结构如下所示(您可以看到资源文件夹,其中包含一个文件SapConfig.json):

然后,我尝试执行fatjar,如下所示:

代码语言:javascript
复制
java -jar SapEvents-assembly-0.1.0.jar 
java.nio.file.FileSystemNotFoundException
        at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
        at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
        at java.nio.file.Paths.get(Paths.java:143)
        at ch.micarna.SapEventServer$.stream(SapEventServer.scala:22)
        at ch.micarna.SapEventServer$.stream(SapEventServer.scala:16)
        at fs2.StreamApp.$anonfun$runStream$1(StreamApp.scala:66)
        at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:128)
        at cats.effect.internals.IORunLoop$.start(IORunLoop.scala:35)
        at cats.effect.IO.unsafeRunAsync(IO.scala:257)
        at cats.effect.IO.$anonfun$runAsync$1(IO.scala:175)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at cats.effect.internals.IORunLoop$.step(IORunLoop.scala:167)
        at cats.effect.IO.unsafeRunTimed(IO.scala:304)
        at cats.effect.IO.unsafeRunSync(IO.scala:239)
        at fs2.StreamApp.main(StreamApp.scala:83)
        at ch.micarna.SapEventServer.main(SapEventServer.scala)

正如您所认识到的,我假设找不到资源文件。

读取资源文件的代码如下所示:

代码语言:javascript
复制
Paths.get(getClass.getClassLoader.getResource("SapConfig.json")  

我应该把我的资源文件放在哪里?

EN

回答 1

Stack Overflow用户

发布于 2018-04-04 18:35:32

我认为您的解决方案在this post中。

仅更改

资源src/

/webapp to src/main/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49629964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档