How do i use play ws library in normal sbt project instead of play?

前端 未结 2 1336
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 16:32

When i tried using Play WS library in a normal sbt project instead of play project I was bound to use play.api.Play.current and got java.lang.RuntimeException:

2条回答
  •  一整个雨季
    2021-02-02 17:08

    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()
    

提交回复
热议问题