代码之家  ›  专栏  ›  技术社区  ›  sekhar

如何解决此异常加载类文件“SprayJsonSupport”时检测到的无效依赖关系。类别'

  •  0
  • sekhar  · 技术社区  · 7 年前

    I'am using我正在使用

    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.
    

    请问我该如何解决这一问题。 非常感谢。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Raman Mishra    7 年前

    请添加最新的spray Json依赖项,并更新您的Akka测试工具包版本、sbt和scala版本。

    当您使用marshaller和unmarshaller时 将case类转换为json,反之亦然。 我认为这应该解决你的问题。

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

    将其添加到依赖项中,使其与Scala 2.11兼容。十、

    但我建议你用新的更新你的依赖关系。