如何声明播放json依赖?

时间:2015-04-17 17:04:14

标签: scala sbt play-json

我的build.sbt文件(sbt版本为0.13.8):

lazy val commonSettings = Seq(
  version := "1.0.0",
  scalaVersion := "2.11.6"
)

resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"

lazy val root = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    name := "myapp",
    libraryDependencies ++= Seq(
      "com.typesafe.play" % "play-json" % "2.3.4",
      "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test",
      "junit" % "junit" % "4.12" % "test"
    )
  )

scalacOptions ++= Seq("-unchecked", "-feature", "-deprecation")

我在尝试编译项目时遇到此错误:

[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.play#play-json_2.11;2.3.4: not found
[error] Total time: 0 s, completed Apr 17, 2015 5:59:28 PM

如何为我的scala 2.11.6获取此play-json库?

2 个答案:

答案 0 :(得分:6)

你需要告诉sbt应该使用哪个scala版本。

你可以是明确的:

"com.typesafe.play" % "play-json_2.11" % "2.3.4",

或者如下使用%%sbt doc)告诉sbt使用scalaVersion

"com.typesafe.play" %% "play-json" % "2.3.4",

答案 1 :(得分:4)

您可以查看所有com.typesafe.playplay-json版本here。他们没有2.3.4版本;请尝试使用2.4.0-M3

"com.typesafe.play" %% "play-json" % "2.4.0-M3"

请注意双%%,以便正确使用scalaVersion来解决依赖关系。