Scala 如何在ReactiveMongo 0.11.11&;中用DI替换电流;游戏2.5

Scala 如何在ReactiveMongo 0.11.11&;中用DI替换电流;游戏2.5,scala,playframework,playframework-2.0,reactivemongo,play-reactivemongo,Scala,Playframework,Playframework 2.0,Reactivemongo,Play Reactivemongo,我使用GitHub Gistby的设计作为数据库层的示例。不幸的是,current自Play 2.5版以来已被弃用,因此我无法使用: trait MongoHelper extends ContextHelper{ lazy val db = ReactiveMongoPlugin.db } 也不是 由于我无法将reactiveMongoApi注入到一个特性中,我想知道如何解决这个问题。尽管不鼓励使用不推荐的方法,但我无法启动我的应用程序,因为我的启动代码在应用程序启动时将虚拟数据

我使用GitHub Gistby的设计作为数据库层的示例。不幸的是,
current
自Play 2.5版以来已被弃用,因此我无法使用:

trait MongoHelper extends ContextHelper{

    lazy val db = ReactiveMongoPlugin.db

}
也不是


由于我无法将
reactiveMongoApi
注入到一个特性中,我想知道如何解决这个问题。尽管不鼓励使用不推荐的方法,但我无法启动我的应用程序,因为我的启动代码在应用程序启动时将虚拟数据插入我的数据库,导致了一个异常
没有启动的应用程序

在trait中可以有一个抽象
def reactiveMongoApi
,实现类必须适当地定义它,可能使用DI(如中所示)。trait中可以有一个抽象
def reactiveMongoApi
,实现类必须适当地定义它,可能使用DI(如中所示)。
trait MongoHelper extends ContextHelper {

  lazy val reactiveMongoApi = current.injector.instanceOf[ReactiveMongoApi]

  lazy val db = reactiveMongoApi.db

}