我花了无数时间试图将Spray json作为依赖项包含在我基于scala 2.10构建的播放项目中。
有人可以为要在项目文件中使用的EXACT魔术指令提供确定的解释吗?!!!!
Build.scala:
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "linscot"
val appVersion = "1.0"
val appDependencies = Seq(
jdbc,
anorm,
"mysql" % "mysql-connector-java" % "5.1.18",
"com.cloudphysics" % "jerkson_2.10" % "0.6.3",
//"cc.spray.json" % "spray-json_2.9.1" %"1.0.1"
"io.spray" % "spray-json_2.10.1" % "1.2.5"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
//libraryDependencies += "io.spray" %% "spray-json" % "1.2.5"
)
}
得到此:
[info] Updating {file:/Users/Joel/Projects/linscot-server/}linscot...
[warn] module not found: io.spray#spray-json_2.10.1;1.2.5
[warn] ==== local: tried
[warn] /Users/Joel/.ivy2/local/io.spray/spray-json_2.10.1/1.2.5/ivys/ivy.xml
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/io/spray/spray-json_2.10.1/1.2.5/spray-json_2.10.1-1.2.5.pom
[warn] ==== Typesafe Snapshots Repository: tried
[warn] http://repo.typesafe.com/typesafe/snapshots/io/spray/spray-json_2.10.1/1.2.5/spray-json_2.10.1-1.2.5.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/io/spray/spray-json_2.10.1/1.2.5/spray-json_2.10.1-1.2.5.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: io.spray#spray-json_2.10.1;1.2.5: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] (*:update) sbt.ResolveException: unresolved dependency: io.spray#spray-json_2.10.1;1.2.5: not found
[warn] some of the dependencies were not recompiled properly, so classloader is not avaialable
[info] Updating {file:/Users/Joel/Projects/linscot-server/}linscot...
[warn] module not found: io.spray#spray-json_2.10.1;1.2.5
[warn] ==== local: tried
[warn] /Users/Joel/.ivy2/local/io.spray/spray-json_2.10.1/1.2.5/ivys/ivy.xml
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/io/spray/spray-json_2.10.1/1.2.5/spray-json_2.10.1-1.2.5.pom
[warn] ==== Typesafe Snapshots Repository: tried
[warn] http://repo.typesafe.com/typesafe/snapshots/io/spray/spray-json_2.10.1/1.2.5/spray-json_2.10.1-1.2.5.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/io/spray/spray-json_2.10.1/1.2.5/spray-json_2.10.1-1.2.5.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: io.spray#spray-json_2.10.1;1.2.5: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] (*:update) sbt.ResolveException: unresolved dependency: io.spray#spray-json_2.10.1;1.2.5: not found
spray-json依赖项的格式是:
"io.spray" %% "spray-json" % "1.2.5"
使用%%
确保您所使用的Scala版本具有正确的版本。
Spray不会使用默认存储库之一来分发库,因此您还必须指定该库。这样的设置将变为:
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += "spray" at "http://repo.spray.io/",
libraryDependencies += "io.spray" %% "spray-json" % "1.2.5"
)
当我无法在项目中使用1.3.2版中的spray-json依赖项时,我遇到了这个问题。 sbt.last.log告诉我:sbt.ResolveException:未解决的依赖项:io.spray#spray-json_2.11; 1.3.2:找不到。事实证明,版本1.3.2中的spray-json工件在http://repo.spray.io存储库中根本不可用。解决方案是改用1.3.1版。
我想在独立的测试项目中使用spray json,但是面临类似的错误。
libraryDependencies += "io.spray" %% "spray-json" % "1.3.4"
来自https://github.com/spray/spray-json没有帮助。
从https://doc.akka.io/docs/akka-http/current/common/json-support.html添加以下依赖项没有给出任何错误。
libraryDependencies += "com.typesafe.akka" %% "akka-http-spray-json" % "10.1.11"