Clojure Uberjar not loading resource file

后端 未结 2 1884
予麋鹿
予麋鹿 2021-01-12 07:23

I use lein uberjar to create a standalone jar of an application.

When executing

java -jar dataloader-0.1.0-SNAPSHOT-standalone.jar,
相关标签:
2条回答
  • 2021-01-12 07:47

    If you want to read the content of the configuration.json file, do not call io/file. Instead, use slurp function, like that:

    (def config (slurp (io/resource "configuration.json")))
    
    0 讨论(0)
  • 2021-01-12 07:50

    clojure.java.io/resource returns a URL, not a file. That's why you can call slurp on it. The error message is telling you that it's not a file, unfortunately it's not telling you that it's a URL.

    Of course you could open the url with the java.net.URL api although that would be overkill in this case.

    0 讨论(0)
提交回复
热议问题