我是Scala和SBT的新手,我試圖找出如何在我的Play 2.0項目中添加lift-json作爲構建依賴項。升降JSON文件說:添加lift-json作爲Play 2.0項目的構建依賴項
Add dependency to your project description:
val lift_json = "net.liftweb" %% "lift-json" % "XXX"
我不知道即使在「項目介紹」實際存儲,但我發現一個Build.scala認爲有以下幾點:
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "test"
val appVersion = "1.0"
val appDependencies = Seq(
// Add your project dependencies here,
"net.liftweb" %% "lift-json" % "2.9.1"
)
val main = PlayProject(appName, appVersion, appDependencies).settings(defaultScalaSettings:_*).settings(
// Add your own project settings here
)
}
你可以看到我爲net.liftweb添加的行。不幸的是,這似乎是一個錯誤的地方,或者錯誤的內容,因爲我得到了下面的生成錯誤:
[info] Updating {file:/D:/play/test/}test...
[warn] module not found: net.liftweb#lift-json_2.9.1;2.9.1
[warn] ==== local: tried
[warn] D:\play\play-2.0-beta\framework\..\repository/local/net.liftweb/lift-json_2.9.1/2.9.1/ivys/ivy.xml
[warn] -- artifact net.liftweb#lift-json_2.9.1;2.9.1!lift-json_2.9.1.jar:
[warn] D:\play\play-2.0-beta\framework\..\repository/local/net.liftweb/lift-json_2.9.1/2.9.1/jars/lift-json_2.9.1.jar
[warn] ==== Play Repository: tried
[warn] http://download.playframework.org/ivy-releases/net.liftweb/lift-json_2.9.1/2.9.1/ivys/ivy.xml
[warn] -- artifact net.liftweb#lift-json_2.9.1;2.9.1!lift-json_2.9.1.jar:
[warn] http://download.playframework.org/ivy-releases/net.liftweb/lift-json_2.9.1/2.9.1/jars/lift-json_2.9.1.jar
[warn] ==== Typesafe Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/net/liftweb/lift-json_2.9.1/2.9.1/lift-json_2.9.1-2.9.1.pom
[warn] -- artifact net.liftweb#lift-json_2.9.1;2.9.1!lift-json_2.9.1.jar:
[warn] http://repo.typesafe.com/typesafe/releases/net/liftweb/lift-json_2.9.1/2.9.1/lift-json_2.9.1-2.9.1.jar
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/net/liftweb/lift-json_2.9.1/2.9.1/lift-json_2.9.1-2.9.1.pom
[warn] -- artifact net.liftweb#lift-json_2.9.1;2.9.1!lift-json_2.9.1.jar:
[warn] http://repo1.maven.org/maven2/net/liftweb/lift-json_2.9.1/2.9.1/lift-json_2.9.1-2.9.1.jar
[warn] ==== Scala-Tools Maven2 Repository: tried
[warn] http://scala-tools.org/repo-releases/net/liftweb/lift-json_2.9.1/2.9.1/lift-json_2.9.1-2.9.1.pom
[warn] -- artifact net.liftweb#lift-json_2.9.1;2.9.1!lift-json_2.9.1.jar:
[warn] http://scala-tools.org/repo-releases/net/liftweb/lift-json_2.9.1/2.9.1/lift-json_2.9.1-2.9.1.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: net.liftweb#lift-json_2.9.1;2.9.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/D:/play/test/}test/*:update: sbt.ResolveException: unresolved dependency: net.liftweb#lift-json_2.9.1;2.9
.1: not found
[error] application -
! @68mcpckf2 - Internal server error, for request [GET /] ->
play.api.UnexpectedException: Unexpected exception [ResolveException: unresolved dependency: net.liftweb#lift-json_2.9.1
;2.9.1: not found]
at sbt.PlayProject$$anon$1$$anonfun$reload$1$$anonfun$apply$36.apply(SbtPlugin.scala:518) ~[play_2.9.1.jar:na]
at sbt.PlayProject$$anon$1$$anonfun$reload$1$$anonfun$apply$36.apply(SbtPlugin.scala:511) ~[play_2.9.1.jar:na]
at scala.Option.map(Option.scala:133) [scala-library.jar:na]
at sbt.PlayProject$$anon$1$$anonfun$reload$1.apply(SbtPlugin.scala:511) ~[play_2.9.1.jar:na]
at sbt.PlayProject$$anon$1$$anonfun$reload$1.apply(SbtPlugin.scala:510) ~[play_2.9.1.jar:na]
at scala.Either$LeftProjection.map(Either.scala:183) ~[scala-library.jar:na]
Caused by: sbt.ResolveException: unresolved dependency: net.liftweb#lift-json_2.9.1;2.9.1: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:216) ~[ivy_2.9.1-0.11.0.jar:na]
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:130) ~[ivy_2.9.1-0.11.0.jar:na]
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:129) ~[ivy_2.9.1-0.11.0.jar:na]
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:110) ~[ivy_2.9.1-0.11.0.jar:na]
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:110) ~[ivy_2.9.1-0.11.0.jar:na]
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:98) ~[ivy_2.9.1-0.11.0.jar:na]
我有提升的源代碼的副本,但我不知道在哪裏把它。而且我很確定我把這個依賴關係放在了錯誤的地方。有人能指點我正確的方向嗎?
有趣的是你想要提升JSON裏面播放2.0。你的推理是什麼?只是好奇。 – andyczerwonka 2012-04-04 04:17:55
那麼,我最終決定使用scala-json(Twitter創建的),但這是因爲我發現與Play一起發佈的JSON庫與其他選項相比很難合作。 – 2012-04-04 14:09:22
我同意,電梯似乎好多了。我還沒有嘗試過Twitter。推特圖書館不會給你什麼?我喜歡Lift case類的處理。 – andyczerwonka 2012-04-04 23:36:34