Akka:缺少akka.version [英] Akka: missing akka.version

查看:437
本文介绍了Akka:缺少akka.version的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个scala项目,该项目在IntelliJ中运行良好,并且将运行/调试配置设置为应用程序,现在我想创建一个jar,以使用 java -jar .jar运行它。这是一个Maven项目,而不是SBT。

I have a scala project which I've been running fine inside IntelliJ with a Run/Debug configuration set to Application, and now I'd like to create a jar to run it using 'java -jar .jar'. This is a maven project, not SBT.

我有三个模块,包括所有其他模块的顶部模块在resources文件夹中具有reference.conf。这是最小的application.conf,没有很多设置。

I have three modules, and the top module which includes all other modules has an reference.conf in the resources folder. It's a minimal application.conf, not a lot of settings. Another one of the modules has its own reference.conf.

我根据最上面的模块创建了一个工件,并对其进行了构建以创建一个jar。当我用java

I created an artifact based on my top module, and I build it to create a jar. When I execute it with java

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.se.pd.Main.main(Main.scala)
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.version'
    at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:145)
    at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:151)
    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.<init>(ActorSystem.scala:168)
    at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:504)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:141)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:118)
    at com.se.pd.ServiceMain$class.$init$(ServiceMain.scala:25)
    at com.se.pd.Main$.<init>(Main.scala:17)
    at com.se.pd.Main$.<clinit>(Main.scala)

解压缩文件时,在根目录中看到合并的reference.conf。

When I unzip the file, I see the merged reference.conf in the root dir.

我缺少什么?创建ActorSystem时需要做一些特定的事情吗?我尝试删除所有配置文件并使用所有默认设置运行,但仍然无法正常运行,尽管在这种情况下,错误从抱怨 akka.version变为抱怨 akka。所以感觉有点不高兴,我只是没有加载akka默认值?

What am I missing? Do I need to do something specific when I create my ActorSystem? I tried deleting all of my config files and running with all defaults, and it still didn't work, although in that case the error changed from complaining about "akka.version" to complaining about "akka". So it feels liek somehow I'm just not loading the akka defaults?

推荐答案

我出于我的目的对其进行了修复,但它没有并没有真正向我澄清问题是什么。
我的解决方法(特定于IntelliJ IDEA)是将工件从以下位置更改:

I fixed it for my purposes, but it doesn't really clarify to me what the issue is. My fix (IntelliJ IDEA specific) was to change the artifact from:


提取到目标JAR

"extract to target JAR"


复制到输出目录并通过清单

"copy to output directory and link via manifest"

我想当我创建一个大的胖子罐时,东西会丢失。

I suppose something gets lost when I create a big fat jar.

-

我只是想添加一个更好的解决方案,用maven创建一个胖罐。但是我不能相信,因为看起来Zoltan在下面链接的Akka页面现在提出了相同的解决方案,老实说,我不记得在哪里找到了。我可能在过去的某个时候碰到了更新的页面。请访问该链接以获取更多信息。

I just wanted to add a better solution to create a "fat jar" with maven. But I can't take credit, since it looks like the Akka page linked below by Zoltan now suggests the same solution, and in all honesty I cannot remember where I found this. I may have run into the updated page at some point in the past. Please consult that link for much better information.

因此:

使用Maven着色器插件来创建脂肪jar
然后确保合并配置文件:

Use the maven shader plugin to create the fat jar Then make sure you merge the configuration files:

<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
          <resource>reference.conf</resource>
     </transformer>
     <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
      <mainClass>myMainClass</mainClass>
</transformer>

使用该配置,我可以成功构建胖罐子。

Using that configuration, I can successfully build fat jars.

这篇关于Akka:缺少akka.version的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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