如何将play-json依赖项添加到项目中?

时间:2014-01-13 15:16:09

标签: playframework playframework-2.0 sbt

我想将play-json依赖项添加到sbt项目中。

我在project/plugins.sbt中添加了Typesafe存储库:

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

然后我在play-json中添加了Build.scala依赖项,如下所示:

libraryDependencies += "com.typesafe.play" % "play-json_2.10" % "2.2.1"

有了这个,我得到如下错误:

[warn]  module not found: com.typesafe.play#play-json_2.10;2.2.1
[warn] ==== local: tried
[warn]   /home/tminglei/.ivy2/local/com.typesafe.play/play-json_2.10/2.2.1/ivys/ivy.xml
[warn] ==== sonatype-snapshots: tried
[warn]   https://oss.sonatype.org/content/repositories/snapshots/com/typesafe/play/play-json_2.10/2.2.1/play-json_2.10-2.2.1.pom
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/typesafe/play/play-json_2.10/2.2.1/play-json_2.10-2.2.1.pom
[info] Resolving org.scala-tools.testing#test-interface;0.5 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.play#play-json_2.10;2.2.1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

如何整理出来?

2 个答案:

答案 0 :(得分:6)

由于依赖项不是插件,因此您只应在项目的主目录中将resolvers设置添加到build.sbt

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

对于这样一个简单的配置,你真的不需要project/*.scala个文件。

答案 1 :(得分:3)

看起来它没有使用您定义的解析器。这对我来说非常适合13:

import sbt._
import Keys._

object Build extends sbt.Build {

  lazy val playjsondep = Project(
    id = "play-json-dep",
    base = file("."),
    settings = Project.defaultSettings ++ Seq(
      name := "play-json-dep",
      organization := "ee.so",
      version := "0.1-SNAPSHOT",
      scalaVersion := "2.10.2",
      resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
      libraryDependencies += "com.typesafe.play" %% "play-json" % "2.2.1"
    )
  )
}