Adding Play JSON Library to sbt

岁酱吖の 提交于 2019-11-26 09:34:33

问题


How can I add the Play JSON library (play.api.libs.json) to my sbt project?

When I added the following to my plugins.sbt file:

addSbtPlugin(\"play\" % \"sbt-plugin\" % \"2.1.0\")

I faced this error:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: play#sbt-plugin;2.1.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

I did not find a resolver for this library, otherwise I would\'ve added it and ran sbt update. Note that my resolvers includes http://repo.typesafe.com/typesafe/releases/.


回答1:


Play 2.3 JSON with SBT >= 0.13.5

put into build.sbt:

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.4"

Play 2.1

build.sbt:

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

scalaVersion := "2.10.2"

libraryDependencies += "play" % "play_2.10" % "2.1.0"

Play JSON is in Play 2.1 not an independent artifact.




回答2:


Play 2.2 is out and can be added separately from rest of Play Framework. in build.sbt:

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

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.2.1"



回答3:


This worked for me (scala 2.11)

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

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.0"




回答4:


You can use the following to get the Play JSON library:

addSbtPlugin("play" % "play-json" % "2.2-SNAPSHOT")

You may also have to include the following resolver:

"Mandubian repository snapshots" at "https://github.com/mandubian/mandubian-mvn/raw/master/snapshots/"

Here's where I originally got the info: http://mandubian.com/2013/02/21/play-json-stand-alone/




回答5:


One could check the Getting Started section of the GitHub repository and add the following to the build.sbt file:

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.0-M1"


来源:https://stackoverflow.com/questions/19436069/adding-play-json-library-to-sbt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!