我如何在普通的 sbt 项目中使用 play ws 库而不是 play? [英] How do i use play ws library in normal sbt project instead of play?

查看:24
本文介绍了我如何在普通的 sbt 项目中使用 play ws 库而不是 play?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在普通 sbt 项目中使用 Play WS 库而不是 play 项目时,我一定会使用 play.api.Play.current 并得到 java.lang.RuntimeException: "没有启动的应用程序" 尝试运行应用程序时.

推荐答案

要在游戏之外使用 play-ws,请参阅文档的使用 WSClient"部分:http://www.playframework.com/documentation/2.3.x/ScalaWS

To use play-ws outside of play see "Using WSClient" section of documentation: http://www.playframework.com/documentation/2.3.x/ScalaWS

val builder = new com.ning.http.client.AsyncHttpClientConfig.Builder()
val client = new play.api.libs.ws.ning.NingWSClient(builder.build())
val response = client.url(url).get()

这篇关于我如何在普通的 sbt 项目中使用 play ws 库而不是 play?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆