![](/img/trans.png)
[英]How to declare dependency on Play's Anorm for a standalone application?
[英]How to declare play json dependency?
我的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庫?
您需要告訴sbt應該使用哪個scala版本。
您可以明確:
"com.typesafe.play" % "play-json_2.11" % "2.3.4",
或者按如下方式使用%%
( sbt doc )告訴sbt使用scalaVersion
:
"com.typesafe.play" %% "play-json" % "2.3.4",
您可以在此處查看com.typesafe.play
的所有play-json
版本。 他們沒有2.3.4
版本; 嘗試改用2.4.0-M3
。
"com.typesafe.play" %% "play-json" % "2.4.0-M3"
注意%%
的兩倍,因此可以正確使用scalaVersion
來解決依賴關系。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.