2

我使用了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?

4

2 回答 2

1

根据有关使用jar 或 bundle的文档:

Akka 的配置方法在很大程度上依赖于每个模块/jar 都有自己的 reference.conf 文件的概念,所有这些都将被配置发现并加载。不幸的是,这也意味着如果您将多个 jar 放入/合并到同一个 jar 中,您还需要合并所有 reference.confs。否则所有默认值都将丢失,Akka 将无法运行。

您可以按照此处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
  }
}

这涵盖了akka.actor.provider它所抱怨的环境等。

于 2016-08-04T07:15:53.140 回答
0

在您使用 Akka 提供的插件设置时,应该有一个以 -allinone.jar 结尾的新 jar 可用。这个罐子是带阴影的罐子。

于 2018-04-28T00:58:24.777 回答