2014-01-13 85 views
3

我想添加play-json依賴到一個sbt項目。如何將play-json依賴項添加到項目中?

我添加類型安全的存儲庫中project/plugins.sbt

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

然後我說在Build.scalaplay-json依賴如下:

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] :::::::::::::::::::::::::::::::::::::::::::::: 

如何整理出來?

+0

文件'plugins.sbt'在哪裏? –

+0

這是它的路徑:/[project_root]/project/plugins.sbt – tminglei

回答

3

它看起來像它不使用您定義的解析器。這對我的作品在SBT 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" 
    ) 
) 
} 
+0

是的,它也適用於我。非常感謝! :D – tminglei

6

由於依賴是不是一個插件,你應該只在你的項目的主目錄中添加resolvers設置build.sbt

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

你真的不需要project/*.scala文件的簡單結構。

+0

明白了,非常感謝^^ – tminglei

相關問題