Lagom / Scala / Maven runAll失败,出现异常:无法创建注入器

时间:2017-04-11 17:24:44

标签: lagom

我使用的是Lagom 1.3.1 [SCALA]

我正在尝试连接外部Cassandra& kafka在pom.xml中有必要的配置。

当我使用mvn lagom:runAll启动服务时,我收到以下错误

Downloading: http://.../.../com/lightbend/lagom/lagom-reloadable-server_2.11/1.3.1/lagom-reloadable-server_2.11-1.3.1.pom
Downloaded: http://.../.../com/lightbend/lagom/lagom-reloadable-server_2.11/1.3.1/lagom-reloadable-server_2.11-1.3.1.pom (6 KB at 52.8 KB/sec)
Downloading: http://.../.../com/lightbend/lagom/lagom-service-registration_2.11/1.3.1/lagom-service-registration_2.11-1.3.1.pom
Downloaded: http://.../.../com/lightbend/lagom/lagom-service-registration_2.11/1.3.1/lagom-service-registration_2.11-1.3.1.pom (6 KB at 48.1 KB/sec)
Downloading: http://.../.../com/lightbend/lagom/lagom-reloadable-server_2.11/1.3.1/lagom-reloadable-server_2.11-1.3.1.jar
Downloading: http://.../.../com/lightbend/lagom/lagom-service-registration_2.11/1.3.1/lagom-service-registration_2.11-1.3.1.jar
Downloaded: http://.../.../com/lightbend/lagom/lagom-reloadable-server_2.11/1.3.1/lagom-reloadable-server_2.11-1.3.1.jar (30 KB at 288.2 KB/sec)
Downloaded: http://.../.../com/lightbend/lagom/lagom-service-registration_2.11/1.3.1/lagom-service-registration_2.11-1.3.1.jar (21 KB at 171.7 KB/sec)
No play.logger.configurator found: logging must be configured entirely by the application.
com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Could not find a suitable constructor in com.lightbend.lagom.internal.javadsl.server.ResolvedServices. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
  at com.lightbend.lagom.internal.javadsl.server.ResolvedServices.class(JavadslServerBuilder.scala:95)
  while locating com.lightbend.lagom.internal.javadsl.server.ResolvedServices
    for parameter 1 at com.lightbend.lagom.internal.server.ServiceRegistrationModule$RegisterWithServiceRegistry.(ServiceRegistrationModule.scala:54)
  at com.lightbend.lagom.internal.server.ServiceRegistrationModule.bindings(ServiceRegistrationModule.scala:28):
Binding(class com.lightbend.lagom.internal.server.ServiceRegistrationModule$RegisterWithServiceRegistry to self eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)

2) Could not find a suitable constructor in com.lightbend.lagom.javadsl.api.ServiceInfo. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
  at com.lightbend.lagom.javadsl.api.ServiceInfo.class(ServiceInfo.java:51)
  while locating com.lightbend.lagom.javadsl.api.ServiceInfo
    for field at com.lightbend.lagom.internal.javadsl.registry.ServiceRegistryClientProvider.serviceInfo(ServiceRegistryModule.scala:62)
  at com.lightbend.lagom.internal.javadsl.registry.ServiceRegistryModule.configure(ServiceRegistryModule.scala:35) (via modules: com.google.inject.util.Modules$OverrideModule -> com.lightbend.lagom.internal.javadsl.registry.ServiceRegistryModule)

2 errors
        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466)
        at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)

我没有在我的代码中使用Guice模块,我正在利用scala的方法将依赖关系与" macwire"连接起来。然而,拉美姆"服务注册"模块依赖于javadsl,它使用guice进行布线。

有关如何解决这个问题的想法吗?

我父pom中的Maven依赖:

modulo

Maven Lagom插件配置:

var text = "";
var i;
var MAX = 528;
for (i = 0; i < MAX; i++) {
    text += "\\I[" + i + "] ";
    
    if(i !==0 && ((i + 1 < MAX) && ((i + 1) % 15 === 0))) {
        text += '<br>';
    }
}
document.getElementById("number").innerHTML = text;

1 个答案:

答案 0 :(得分:0)

目前,Lagom不支持将Maven与Scala API一起使用,仅支持sbt。将Maven与Lagom结合使用需要使用Java API。