3

我花了无数个小时试图让 Spray json 作为依赖项包含在我基于 scala 2.10 构建的 play 项目中。

有人可以为这个东西在项目文件中使用的确切魔法咒语提供明确的解释吗?!!!!!!

构建.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
4

3 回答 3

5

spray-json 依赖的格式为:

"io.spray" %%  "spray-json" % "1.2.5"

Using%%可确保您获得与您正在使用的 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"
)
于 2013-09-19T10:29:38.043 回答
0

当我无法在我的项目中使用版本 1.3.2 中的 spray-json 依赖项时,我遇到了这个问题。sbt.last.log 告诉我:sbt.ResolveException: unresolved dependency: io.spray#spray-json_2.11;1.3.2: not found。事实证明,1.3.2 版中的 spray-json 工件在http://repo.spray.io存储库中根本不可用。解决方案是改用 1.3.1 版本。

于 2015-04-08T11:18:19.220 回答
0

我想在独立测试项目中使用 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"
于 2019-12-25T15:21:54.093 回答