I am exploring play-scala 2.4.2 and trying to get the spring DI working with it. I see there are a lot of changes in play 2.4.x and old way of overriding the GlobalSettings.getC
The latest version of Play:
Create the class Global (Old Global than extended GlobaSettings):
@Singleton
public class Global {
private static final String APPLICATION_CONTEXT = "applicationContext.xml";
private ConfigurableApplicationContext applicationContext;
@Inject
public Global( ApplicationLifecycle lifecycle ) {
applicationContext = new ClassPathXmlApplicationContext(APPLICATION_CONTEXT_XML);
lifecycle.addStopHook( () -> {
applicationContext.close();
return F.Promise.pure( null );
});
}
}
Create the class ConfigurableApplicationContextModule:
public class ApplicationContextModule extends AbstractModule {
@Override
protected void configure() {
bind( Global.class ).asEagerSingleton();
}
}
In application.conf add this:
play.modules.enabled += "config.ApplicationContextModule"
Create file applicationContext.xml:
After creating what stated above by Ranga