【问题标题】:How to resolve this exception invalid dependency detected while loading class file 'SprayJsonSupport.class'如何解决加载类文件“SprayJsonSupport.class”时检测到的异常无效依赖项
【发布时间】:2018-09-20 03:15:37
【问题描述】:

我正在使用

version := "1.0"
scalaVersion := "2.11.8"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

libraryDependencies ++= {
  val akkaV = "2.4.18"
  val scalaTestV = "2.2.6"
  val akkaHttpV = "10.0.10"
}

我试图运行我的测试用例,但它显示这样的错误

  Error:scalac: missing or invalid dependency detected while loading class file 'SprayJsonSupport.class'.
    Could not access type FromByteStringUnmarshaller in package akka.http.scaladsl.unmarshalling.package,
    because it (or its dependencies) are missing. Check your build definition for
    missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
    A full rebuild may help if 'SprayJsonSupport.class' was compiled against an incompatible version of akka.http.scaladsl.unmarshalling.package.

我该如何解决这个问题,请在这里提出建议。 谢谢。

【问题讨论】:

    标签: scala unit-testing akka


    【解决方案1】:

    请添加最新的 spray Json 依赖,同时更新你的 Akka-test kit 版本、sbt 和 scala 版本。

    当你使用 marshaller 和 unmarshaller 将您的案例类转换为 json,反之亦然。 我认为它应该可以解决您的问题。

    libraryDependencies += "io.spray" %% "spray-json" % "1.3.1"
    

    将此添加到您的依赖项中,它与 Scala 2.11.x 兼容

    但我建议您使用新的依赖项更新所有依赖项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-06
      • 1970-01-01
      • 1970-01-01
      • 2015-03-12
      • 2017-06-12
      • 2019-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多