Play: How to read a config parameter from application.conf file (post 2.5.x)

Post 2.5.x release, older approach of having Global objects to access configuration parameters available in application.conf is no longer recommended. Instead, it is advised now to use dependency injection to access these.

Here is the older way to access config parameters:

// older approach
import play.api.Play
val value = Play.current.configuration.getString("confKey")

which gives following warning now during compilation.

[warn] Example.scala:21: method current in object Play is deprecated: This is a static reference to application, use DI instead
[warn]     val value = Play.current.configuration.getString("confKey")

Newer and better way to access the configuration is following:

// new approach post 2.5.x

import javax.inject.Inject
import play.api.Configuration

class Example @Inject() (playconfiguration: Configuration) {
	def index() = {
        val confString: String = playconfiguration.getString("confKey").get
Category: play-framework scala