I have a module in my Play 2.6.11 app which I want to enable like
play.modules.enabled += "my.Module"
This works great if I use the default (Guice) application loader provide by Play. However, I also need my custom application loader like
play.application.loader = MyApplicationLoader
Together, my.Module
is not instantiated.
Does anyone has experience using these 2 together? I have a hard time finding relevant documentation about this as well.
The Play module docs don't mention custom application loaders.
You can do this the following way
Custom loader
import play.api.{Application, ApplicationLoader}
class CustomLoader extends ApplicationLoader {
def load(context: ApplicationLoader.Context): Application =
new CustomModule(context).application
}
In application.conf
application.loader = CustomLoader
CustomModule
can load all other components.
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.