As stated in Play Slick documentation a DatabaseConfig object can be obtained via Global Lookup:
val dbConfig = DatabaseConfigProvider.get[JdbcProfile](Play.current)
However I get the following compilation warning stating that current
is deprecated and that I should use DI instead:
[warn] C:\myapp\app\test\Test.scala:28: method current in object Play is deprecated: This is a static reference to application, use DI instead
Am I forced to use DI instead of global lookup? With the deprecation warning the database connection works fine.
Either inject actually Play app (and pass it as parameter as you did) or better, inject DatabaseConfigProvider
itself - in that way it won't need Application:
@Singleton
class DbAccessPlayConfig @Inject()(dbConfigProvider: DatabaseConfigProvider) {
val dbConfig = dbConfigProvider.get[JdbcProfile]
}