3

I thought since akka 2.1.4 uses typesafe config, it would just override whatever -D parameter I throw at it via command line, like play framework does. Turns out it doesn't seem to work that way. Just adding a -Dakka.remote.netty.port=2552 doesn't really change anything when added in to the commandline. Do I have to enable anything to make overrides work?

Additional info: I tried using the -D parameters in the Intellij launcher and with java -cp app.jar -Dakka.remote.netty.port=2552 after doing an sbt assembly

4

2 回答 2

6

好吧,我发现我做错了什么。application.conf当仅加载一部分时,似乎覆盖不起作用。-Dakka.remote.netty.port=2553当您通过仅从application.conf加载特定部分来配置参与者系统时,您无法覆盖 netty 端口,如下所示:

val system = ActorSystem("myActorSystem",ConfigFactory.load.getConfig("client"))

应用程序.conf 文件:

client{
  akka {

  log-config-on-start = on
   loglevel = "INFO"
   actor {
      provider = "akka.remote.RemoteActorRefProvider"
      include "serialization.conf"
   }

   remote {
    transport = "akka.remote.netty.NettyRemoteTransport"
    netty {
      hostname = "127.0.0.1"
      port = 2552
    }
    log-sent-messages = off
    log-received-messages = off
   }
  }
}

在这种情况下,尽管您将“client”指定为要加载的小节,但您仍然必须将“client”作为您的值的键,这将通过使用命令行参数覆盖它们。

但请注意,配置文件中的值在以这种方式加载时不会由“客户端”添加。因此,通过使用-Dclient.akka.remote.netty.port=2553,您可以像习惯一样有效地覆盖。

于 2013-05-27T19:28:46.083 回答
4

我遇到了同样的问题。我使用'java -jar project.jar -Dblah=whatever'来运行没有覆盖conf文件的项目。但是,'java -jar -Dblah=whatever project.jar' 确实覆盖了 conf 文件。

于 2014-08-21T19:09:25.493 回答