我使用了akka docs中给出的maven-shade-plugin,它创建了一个阴影jar,如maven build的以下输出所示:
[INFO] --- maven-shade-plugin:2.4.2:shade (default) @ remoting.example ---
[INFO] Including com.typesafe.akka:akka-remote_2.11:jar:2.4.8 in the shaded jar.
[INFO] Including org.scala-lang:scala-library:jar:2.11.8 in the shaded jar.
[INFO] Including com.typesafe.akka:akka-protobuf_2.11:jar:2.4.8 in the shaded jar.
[INFO] Including io.netty:netty:jar:3.10.6.Final in the shaded jar.
[INFO] Including org.uncommons.maths:uncommons-maths:jar:1.2.2a in the shaded jar.
[INFO] Including com.typesafe.akka:akka-actor_2.11:jar:2.4.8 in the shaded jar.
[INFO] Including com.typesafe:config:jar:1.3.0 in the shaded jar.
[INFO] Including org.scala-lang.modules:scala-java8-compat_2.11:jar:0.7.0 in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /home/dschulze/src/java/akka/remoting.example/target/remoting.example-0.0.1-SNAPSHOT.jar with /home/dschulze/src/java/akka/remoting.example/target/remoting.example-0.0.1-SNAPSHOT-shaded.jar
[INFO] Dependency-reduced POM written at: /home/dschulze/src/java/akka/remoting.example/dependency-reduced-pom.xml
当我运行jar-with-dependencies时,我仍然得到
Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.version'
我还尝试了其他几个我在网上的各种帖子中找到的内容,但是没有一个创建了一个可以运行的jar-with-dependencies。如何创建使用akka的jar-with-dependencies?
答案 0 :(得分:1)
根据有关使用jar or bundle的文档:
Akka的配置方法在很大程度上依赖于每个具有自己的reference.conf文件的模块/ jar的概念,所有这些都将由配置发现并加载。不幸的是,这也意味着如果你将多个jar放入/合并到同一个jar中,你需要合并所有的reference.confs。否则所有默认值都将丢失,Akka将无法正常运行。
您可以按照here所述提供自定义componentDidUpdate()
:
application.conf
这包括其抱怨的akka {
# Loggers to register at boot time (akka.event.Logging$DefaultLogger logs
# to STDOUT)
loggers = ["akka.event.slf4j.Slf4jLogger"]
# Log level used by the configured loggers (see "loggers") as soon
# as they have been started; before that, see "stdout-loglevel"
# Options: OFF, ERROR, WARNING, INFO, DEBUG
loglevel = "DEBUG"
# Log level for the very basic logger activated during ActorSystem startup.
# This logger prints the log messages to stdout (System.out).
# Options: OFF, ERROR, WARNING, INFO, DEBUG
stdout-loglevel = "DEBUG"
# Filter of log events that is used by the LoggingAdapter before
# publishing log events to the eventStream.
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
actor {
provider = "akka.cluster.ClusterActorRefProvider"
default-dispatcher {
# Throughput for default Dispatcher, set to 1 for as fair as possible
throughput = 10
}
}
remote {
# The port clients should connect to. Default is 2552.
netty.tcp.port = 4711
}
}
设置等。
答案 1 :(得分:0)
在使用Akka提供的插件设置时,应该有一个以-allinone.jar结尾的新jar。这个罐子是阴影罐子。