使用shadowJar和Scala依赖项时如何解决丢失的conf文件? [英] How can I fix missing conf files when using shadowJar and Scala dependencies?

查看:343
本文介绍了使用shadowJar和Scala依赖项时如何解决丢失的conf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为像我这样将来遇到问题的用户撰写本文.基于Typesafe配置的库通常使用其自己的reference.conf文件并引用某些配置密钥.使用Gradle shadowJAR插件构建胖JAR时,不包含这些文件.

Writing this for users who have future issues like me. Libraries that are built on the Typesafe config typically use their own reference.conf files and refer to certain configuration keys. When building a fat JAR using the Gradle shadowJAR plugin, these files aren't included.

当胖JAR尝试运行时,诸如Spray和Akka之类的依赖项会引发错误.错误如下:

Dependencies like Spray and Akka throw errors when the fat JAR attempts to run. Errors look like:

Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'spray'
Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka'

如何解决此问题?检查下面的答案.

How to fix this? Check the answer below.

推荐答案

最终的解决方法是将以下内容添加到build.gradle文件中:

The resulting fix was to add the following to the build.gradle file:

shadowJar {
  transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer) {
    resource = 'reference.conf'
  }
}

在这里找到解决方案: http://www .sureshpw.com/2015/10/building-akka-bundle-with-all.html

Solution was found here:http://www.sureshpw.com/2015/10/building-akka-bundle-with-all.html

这篇关于使用shadowJar和Scala依赖项时如何解决丢失的conf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆