scala 找不到密钥 akka 的配置设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28365000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
no configuration setting found for key akka
提问by Rahul Dev
I am using scala, spray and akka for one of my projects. In Intellij, it is working fine. When I build the project and tried to run it in command line, I get the following error.
我在我的一个项目中使用了 scala、spray 和 akka。在 Intellij 中,它运行良好。当我构建项目并尝试在命令行中运行它时,出现以下错误。
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting
found for key 'akka'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:147)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:159)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:164)
at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:206)
at akka.actor.ActorSystem$Settings.(ActorSystem.scala:168)
at akka.actor.ActorSystemImpl.(ActorSystem.scala:504)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:141)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:108)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:99)
Please help me in solving the issue
请帮我解决问题
回答by BenjaminParker
The problem is when using sbt:assembly the default merge strategy excludes all the reference.conf files as per
问题是在使用 sbt:assembly 时,默认合并策略会按照以下方式排除所有 reference.conf 文件
If multiple files share the same relative path (e.g. a resource named application.conf in multiple dependency JARs), the default strategy is to verify that all candidates have the same contents and error out otherwise.
如果多个文件共享相同的相对路径(例如,多个依赖项 JAR 中名为 application.conf 的资源),默认策略是验证所有候选文件具有相同的内容,否则会出错。
The solution is to add a MergeStrategy as follows
解决方法是添加一个 MergeStrategy 如下
assemblyMergeStrategy in assembly := {
case PathList("reference.conf") => MergeStrategy.concat
}
回答by LynxZh
Akka will read the configuration file from the following location by default:
Akka 默认会从以下位置读取配置文件:
- application.conf under root of classpath (including in jar)
- manually passed in configuration from ActorSystem("name", config).
- reference.conf under root of classpath (including in jar)
- 类路径根目录下的 application.conf(包括在 jar 中)
- 从 ActorSystem("name", config) 手动传入配置。
- 类路径根目录下的reference.conf(包括在jar中)
Please double check your classpath and see if you have a bad classpath reference which indicate a bad root of classpath for akka jars, spray jars, etc.
请仔细检查您的类路径,看看您是否有一个错误的类路径引用,这表明 akka jars、spray jars 等的类路径根目录错误。
回答by skwon
maven-shade-plugin configuration for maven users:
maven 用户的 maven-shade-plugin 配置:
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
</transformers>
</configuration>

