简体   繁体   中英

Play get instance of DatabaseConfigProvider

I'm use Slick as a Play module. In this way, DatabaseConfigProvider will be injected to Controller.
In a special stage, I want get DatabaseConfigProvider out of Controller.
How can I get DatabaseConfigProvider instance?

You can inject it like this:

class MyClass @Inject() (protected val dbConfigProvider: DatabaseConfigProvider)
    extends HasDatabaseConfigProvider[MyPostgresDriver]

With these imports:

import javax.inject.Inject
import database.MyPostgresDriver
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import database.MyPostgresDriver.api._

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM