我已经浏览了2.6.x Migration Guide和WS Migration Guide并且已经完成了大部分初始错误,但我似乎无法完成应用程序启动时出现的这个错误:
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 Migration指南提到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
)
plugins.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")
答案 0 :(得分:1)
这可能是由一些依赖地狱造成的。由于您要添加play-mailer
5.0.0-M1
,这不是最终版本,而是里程碑(API仍然不稳定),我怀疑这是导致问题的原因。
尝试使用以下版本的播放邮件:
"com.typesafe.play" %% "play-mailer" % "6.0.1"
答案 1 :(得分:1)
在this amazing plugin的帮助下,我终于看到了:
"com.elemica" %% "apollo-commons" % "0.1.47-SNAPSHOT"
正在拉入旧的 play-java-ws_2.11 库并导致问题。
我将这种依赖性转移到链条上,这似乎解决了这个问题,但由于订单无法得到保证(正如下面的marco提到的那样),我更新了apollo-commons项目以使用play 2.6.6以及现在不再引用过时的类文件。