我正在使用 Scala Play 框架 2.5,我想使用依赖注入将 WSClient 的实例注入到我的自定义类中,但我不断收到以下错误。
not enough arguments for constructor TestClass: (ws: play.api.libs.ws.WSClient)service.TestClass. Unspecified value parameter ws.
运行以下代码时出现错误
class TestClass @Inject() (ws: WSClient) {
def doSomething() : Future[WSResponse] = {
ws.url("http://www.google.com").get()
}
}
val test = new TestClass()
val f = test.doSomething()
val result = Await.result(f, Duration.Inf)
println("doSomething: " + result)
有人可以帮我解决尝试将 wsclient 依赖项注入自定义类的问题吗?
提前谢谢你
弗朗西斯