私は、プレイのConfigurationインスタンスとWSClientインスタンスに依存するapiサービスクラスを持っています。Macwireでプレイの依存関係を設定できない
と私はMacwireとコンパイル時の注入を使用したい@Inject()注釈の原因を使用したくないので、私がやったことはこれです:
// this is a trait that here im wiring all the dependencies that my api service needs
trait ApiDependencies {
lazy val conf: Configuration = wire[Configuration]
lazy val wsc: WSClient = wire[WSClient]
}
// this is the api service
class ApiService extends ApiDependencies {
def getInfo (id: String): Future[Option[Info]] = {
wsc.url("...").withHttpHeaders(("Content-Type", "application/json")).get.map { response =>
response.status match {
case Status.OK => ...
case Status.NO_CONTENT => ...
case _ => throw new Exception()
}
}
}
}
が、私は、コンパイラのエラーを取得:
をError: Cannot find a value of type: [com.typesafe.config.Config]
lazy val conf: Configuration = wire[Configuration]Error: Cannot find a public constructor nor a companion object for [play.api.libs.ws.WSClient] lazy val wsc: WSClient = wire[WSClient]
誰かがこの問題を解決する方法を知っていますか?なぜ起こっているのですか:/
ありがとう!
[MacWireでサービスに依存関係を注入する方法(フレームワークをプレイする方法)](https://stackoverflow.com/questions/44875361/how-to-inject-dependencies-to-a-service-with- –