I need to read some configuration values just after the configuration file has been loaded but before the application actually starts.
In Play 2.3.x I used to override GlobalSettings.onLoadConfig
, which is deprecated in Play 2.4.x. The official documentation says one should use GuiceApplicationBuilder.loadConfig
instead.
Again, the documentation is a bit poor and I was unable to find more details or an example... so any help would be really appreciated.
1. Before app starts
If you need to read configuration before app starts, this approach can be used:
modules/CustomApplicationLoader.scala
:conf/application.conf
has the following added:With that, I see the following in console (snipped as too long):
Source: documentation.
2. Not before app starts
If you don't need to read configuration before app starts, this approach can be used instead: (it's so embarrassingly simple) the
Module
bindings method takes a Play Environment and Configuration for you to read: