7
我目前使用Play.current的方式如下。Play.current在播放中已棄用2.5
import play.api.{Logger, Play}
object ApplicationConfig {
val app = Play.current
def getConfInt(key: String): Option[Int] = {
val result = app.configuration.getInt(key)
result
}
}
自從遷移到2.5,我已經警告說,它已被棄用與
「這是一個靜態的參考應用程序,使用DI而不是」
然而, doc並不完全說我該如何使用DI。
感謝
是否可以這樣做: configuration.getInt(「some.config.key 「).getOrElse(-1)? – Scipion
這非常好!你可以在這裏看到API文檔:https://www.playframework.com/documentation/2.5.x/api/scala/index.html#[email protected]%28path:String%29:Option[Int] – Anton