是否可以在不安装Play的情况下使用JSON库? [英] Is it possible to use JSON library without installing Play?
本文介绍了是否可以在不安装Play的情况下使用JSON库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的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
库?
It compiles well. Now in code I use import play.api.libs.json._
but the compiler gives error saying "not found: object play". Obviously I did not install play. Is it possible to use play-json
library without installing Play?
推荐答案
考虑这个简单的sbt项目:
Consider this simple sbt project:
build.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中进行清理,重新加载,更新和编译.
Yes, you can have play-json without Play. If it is not working in your project, try restarting SBT or do clean, reload, update, compile in SBT.
这篇关于是否可以在不安装Play的情况下使用JSON库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文