0

我已经阅读了 2.6.x迁移指南WS 迁移指南,并且已经解决了大多数初始错误,但我似乎无法通过应用程序启动时发生的这个错误:

CreationException: Unable to create injector, see the following errors: 
1) Could not find a suitable constructor in play.api.libs.ws.ahc.AhcWSClientConfig. 
Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private. 
at play.api.libs.ws.ahc.AhcWSClientConfig.class(AhcConfig.scala:37) while locating play.api.libs.ws.ahc.AhcWSClientConfig for the 1st parameter of play.libs.ws.ahc.AhcWSAPI.<init>(AhcWSAPI.java:28) 
at play.libs.ws.ahc.AhcWSModule.bindings(AhcWSModule.java:23): Binding(interface play.libs.ws.WSAPI to ConstructionTarget(class play.libs.ws.ahc.AhcWSAPI)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)

WS 迁移指南提到 WSAPI 已被弃用,但似乎 GUICE 仍在尝试绑定到已实现的类?我真的不确定。

如果有帮助,请查看我的 libraryDependencies。

  libraryDependencies ++= Seq(
  javaJpa,
  "org.hibernate" % "hibernate-entitymanager" % "5.1.0.Final",
  "org.postgresql" % "postgresql" % "9.4.1208.jre7",
  "com.elemica" %% "apollo-commons" % "0.1.47-SNAPSHOT",
  "com.jayway.jsonpath" % "json-path" % "2.1.0",
  "com.typesafe.play" %% "play-mailer" % "5.0.0-M1",
  "com.rabbitmq" % "amqp-client" % "3.6.2",
  "org.freemarker" % "freemarker" % "2.3.25-incubating",
  "com.amazonaws" % "aws-java-sdk" % "1.11.133",
  "org.redisson" % "redisson" % "2.1.4",
  "com.h2database" % "h2" % "1.4.196",
  ws,
  guice,
  openId
)

插件.sbt:

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.6")

// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.11")
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.2.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
4

2 回答 2

1

marcospereira 的回答肯定是在正确的道路上!这是依赖冲突问题。我注意到它抱怨的类实际上是在一个旧库(play.libs.ws.WSAPI)上,但不确定该依赖项是如何添加到我的项目中的。

在这个惊人的插件的帮助下,我终于看到了:

"com.elemica" %% "apollo-commons" % "0.1.47-SNAPSHOT"正在拉入旧的play-java-ws_2.11库并导致问题。

我将该依赖项移到了链条中,这似乎可以解决它,但是由于无法保证顺序(正如下面的 marco 所提到的),我更新了 apollo-commons 项目以使用 play 2.6.6,现在是过时的类文件不再被引用。

于 2017-10-20T15:51:57.320 回答
1

这可能是由一些依赖地狱引起的。由于您要添加play-mailer 5.0.0-M1,这不是最终版本,而是一个里程碑(API 仍然不稳定),我怀疑这是问题的原因。

尝试使用以下版本的 play-mailer:

"com.typesafe.play" %% "play-mailer" % "6.0.1"
于 2017-10-20T05:12:58.637 回答