在我的build.sbt
:
lazy val commonSettings = Seq(
version := "1.0.0",
scalaVersion := "2.11.6"
)
lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
name := "myapp",
libraryDependencies ++= Seq(
"com.typesafe.play" % "play-json_2.11" % "2.3.4",
"org.scalatest" % "scalatest_2.11" % "2.2.4" % "test",
"junit" % "junit" % "4.12" % "test"
)
)
resolvers ++= Seq("Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/")
它汇编得很好。现在在代码中我使用import play.api.libs.json._
但是编译器给出了错误说"未找到:对象播放"。显然我没有安装游戏。是否可以在不安装Play的情况下使用play-json
库?
答案 0 :(得分:8)
考虑这个简单的sbt项目:
build.sbt
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.3.4"
)
resolvers ++= Seq("Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/")
然后你可以运行:
sbt console
import play.api.libs.json._
Json.parse("{}")
> res0: play.api.libs.json.JsValue = {}
是的,你可以玩没有Play的play-json。如果它在您的项目中不起作用,请尝试重新启动SBT或在SBT中进行清理,重新加载,更新,编译。