I spent some time trying to create an project using playframework 2.4 and play-slick module with compile time DI.
So I translated the play-slick di sample to use compile time di.
The sample features:
- Evolutions
by mixing
with SlickComponents with SlickEvolutionsComponents with EvolutionsComponents
intoApplicationComponents
and initializing evolutions when the app starts.
class ApplicationComponents(context: Context) extends BuiltInComponentsFromContext(context)
with SlickComponents with SlickEvolutionsComponents with EvolutionsComponents {
...
// This is required by EvolutionsComponents
lazy val dynamicEvolutions: DynamicEvolutions = new DynamicEvolutions
def onStart() = {
// applicationEvolutions is a val and requires evaluation
applicationEvolutions
}
onStart()
}
- In memory database configuration for tests
- Access to your your app components from tests by using a specs2 scope:
"CatDAO" should {
"work as expected" in new WithApplicationComponents {
val dao: CatDAO = appComponents.catDao
..
}
}
I did a pull-request to play-slick project, but it's still to be merged.