Previously in Play! v1 it was really easy to define configuration variables in application.conf
and then access them like so:
play.configuration("db.driver")
However now I can't find anything in the documentation for similar uses in v2 or a proper alternative. What's the method for doing so?
An application configuration file is an XML file used to control assembly binding. It can redirect an application from using one version of a side-by-side assembly to another version of the same assembly. This is called per-application configuration.
Creating a Typesafe Config With Fallbacks In this case, we first load our overrides. conf , then set a fallback of our defaults. conf from above. When searching for any property, it will first search the original config, then traverse down the fallbacks until a value is found.
The Play 2.0 Scala equivalent to this would be:
Play.current.configuration.getString("db.driver")
You will also need import play.api.Play
The full docs for this are here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With