playframework - Play.current is deprecated in play 2.5 -


i using play.current in following way.

import play.api.{logger, play}  object applicationconfig {    val app = play.current   def getconfint(key: string): option[int] = {     val result = app.configuration.getint(key)     result   } } 

since migrating 2.5, have warning saying deprecated

"this static reference application, use di instead"

however, doc doesn't how supposed use di instead.

thanks

depending on use case should use environment, applicationlifecycle , configuration instead of application

in case interested in configuration way in play 2.5.x this:

class homecontroller @inject() (configuration: play.api.configuration) extends controller {    def config = action {     ok(configuration.underlying.getint("some.config.key"))   }  } 

the example provided controller can use approach on other places in application. didn't applicationconfig object provided - consider refactoring when migrating play 2.5.x - di way go


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -