【问题标题】:Integration Akka with Spring and OSGI (No configuration setting found for key 'akka')将 Akka 与 Spring 和 OSGI 集成(未找到密钥“akka”的配置设置)
【发布时间】:2013-05-17 21:39:13
【问题描述】:

我已在我的应用中添加了一个 Akka 演员,可与 SpringOSGI 配合使用。

我尝试像这样使用来自Spring @Component bean 的Actor:

private final ActorSystem system = ActorSystem.create("actor-system");
private ActorRef managerActorRef = system.actorOf(Props.create(ManagerActor.class), "ldapManagerActor");

当我启动应用程序时,它会引发异常 (No configuration setting found for key 'akka'):

Instantiation of bean failed; nested exception is org.springframework.
beans.BeanInstantiationException: Could not instantiate bean class [com.myconpany....ByBean]: Constructor threw exception; nested exception is com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka'

我看过this: doc。似乎我的问题的根源与class loader 有关,我应该将其传递给/用于描述此问题的akka-systemapplication.conf 文件。

但到目前为止,我找不到合适的 stets 来完成所有工作。

有人可以帮忙吗?


我的尝试:

流动的this 文章。

当我输入时:

<bean id="actorSystem" class="akka.actor.ActorSystem" factory-method="create" scope="singleton"></bean>

我有类似的错误:

Could not autowire field: private akka.actor.ActorSystem

com.typesafe.config.ConfigException$Missing: No configuration setting fou
nd for key 'akka'

【问题讨论】:

  • 你有没有 application.conf 文件,如果有,你能把它贴出来,并告诉我该文件是否在类路径的根目录下可用。
  • 已经有了。我刚刚把 akka-actor_.jar/referece.conf 的所有内容都放在那里。它似乎开始工作了。很快就会检查。

标签: spring configuration osgi classloader akka


【解决方案1】:

如果您只想使用 Akka 演员,则无需传入 application.conf 设置。您可以只使用默认值。确保你的类路径上有配置库。

您没有提及您使用的是什么版本的 Akka,但是如果您使用最新的 Akka 2.2 RC,您可以使用 IndirectActorProducer 来处理弹簧接线。

请参阅这篇文章了解如何做到这一点; http://blog.nemccarthy.me/?p=272

您还应该告诉 Spring 在 ActorSystem 上调用 shutdown 以彻底关闭。还有一个关于如何将 ActorSystem 集成到 Spring 或 web 应用程序中的更新指南here

【讨论】:

    猜你喜欢
    • 2023-03-21
    • 2018-04-15
    • 2015-01-11
    • 1970-01-01
    • 1970-01-01
    • 2015-09-09
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多