Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Play! 2.0 configuration variables in application.conf?

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?

like image 629
crockpotveggies Avatar asked Mar 25 '12 04:03

crockpotveggies


People also ask

What is application conf file?

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.

How do I use Typesafe config?

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.


1 Answers

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.

like image 147
Alex Varju Avatar answered Sep 28 '22 00:09

Alex Varju