Akka从源代码修改创建配置文件

Akka从源代码修改创建配置文件,第1张

Akka从源代码修改/创建配置文件

是的,您可以在代码中修改或创建配置。以下摘录来自Akka
文档:

以编程方式修改配置的示例:

// make a Config with just your special settingConfig myConfig = ConfigFactory.parseString("something=somethingElse");// load the normal config stack (system props, then application.conf, then reference.conf)Config regularConfig = ConfigFactory.load();// override regular stack with myConfigConfig combined = myConfig.withFallback(regularConfig);// put the result in between the overrides (system props) and defaults againConfig complete = ConfigFactory.load(combined);// create ActorSystemActorSystem system = ActorSystem.create("myname", complete);

以编程方式创建配置的示例(这在Scala中,但是您可以将其适应Java):

import akka.actor.ActorSystemimport com.typesafe.config.ConfigFactoryval customConf = ConfigFactory.parseString("""  akka.actor.deployment {    /my-service {      router = round-robin-pool      nr-of-instances = 3    }  }""")// ConfigFactory.load sandwiches customConfig between default reference// config and default overrides, and then resolves it.val system = ActorSystem("MySystem", ConfigFactory.load(customConf))


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5562035.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-14

发表评论

登录后才能评论

评论列表(0条)

保存