是的,您可以在代码中修改或创建配置。以下摘录来自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))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)