由play.api.libs.ws.ahc.AhcWSClientConfig。<init>引起的致命执行错误

时间:2019-05-16 07:31:02

标签: scala playframework netty

已升级为可播放2.6,并使用了其他依赖项,例如

build.sbt

libraryDependencies ++= Seq(
      javaWs,
      guice,
           ws,
           "com.typesafe.play" %% "play-json" % "2.6.0",
           "com.typesafe.play" %% "play-ahc-ws-standalone" % "2.0.2"
         ).map(_.excludeAll(
           ExclusionRule(organization = "org.slf4j"),
           ExclusionRule(organization = "com.fasterxml.jackson.core")
           //, ExclusionRule(organization = "io.netty")  //TODO: need it, check for emebeddedCassandra
         )),
         dependencyOverrides += "com.google.guava" % "guava" % "19.0", 
         dependencyOverrides +=  "io.netty" % "netty-transport" % "4.1.16.Final",
         dependencyOverrides +=  "io.netty" % "netty-all" % "4.1.16.Final", 
         dependencyOverrides +=  "io.netty" % "netty-handler" % "4.1.16.Final",
         dependencyOverrides += "io.netty" % "netty-common" % "4.1.16.Final"
       )

pluing.sbt

resolvers += Classpaths.sbtPluginReleases

       // Use the Play sbt plugin for Play projects
       addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.21")

       // https://github.com/scoverage/sbt-scoverage
       addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")


       addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")

       // http://www.scalastyle.org/sbt.html
       addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")

       // https://github.com/sbt/sbt-scalariform
       addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")

甚至添加了"com.typesafe.play" %% "play-ahc-ws-standalone" % "2.0.2" 但得到同样的错误。 有人可以告诉我这是怎么回事吗?

[error] ! 
23:10:54 [error]  java.lang.NoSuchMethodError: Fatal execution error, caused by play.api.libs.ws.ahc.AhcWSClientConfig.<init>(Lplay/api/libs/ws/WSClientConfig;IILscala/concurrent/duration/Duration;Lscala/concurrent/duration/Duration;IIZZ)V (AhcWSClient.scala:66)
23:10:54 [error] play.api.libs.ws.ahc.AhcWSClient$.apply$default$1(AhcWSClient.scala:66)

如何致电WSClient

import play.api.libs.ws.WSClient
import play.api.libs.ws.ahc.AhcWSClient
    def applyOverrides()(implicit ec: ExecutionContext, rc: RequestContext): AppConfiguration = {

        val system = ActorSystem("AppConfiguration")
        val materializer = ActorMaterializer()(system)

        val client = AhcWSClient()(materializer)

        try {
          platform match {
            case AppPlatform.WIGGLES =>
              applyWigglesOverrides(client)

            case AppPlatform.NEUTRON =>
              applyNeutronOverrides(client)

            case AppPlatform.ORCHARD =>
              applyNeutronOverrides(client)
          }
        } finally {
          client.close()
          Await.result(system.terminate(), Duration.Inf)
        }
      }

0 个答案:

没有答案