我在Play Scala项目的 TransactionID
1
2
3
4
5
6
7
8
9
中有secret key
。
application.conf
如何在我的控制器或服务中使用它?
我尝试了# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
application.secret="........"
,它给了我错误application.secret
。它给出了value secret is not a member of controllers.Application
play.crypto.secret
答案 0 :(得分:3)
播放提供Configuration
对象以从application.conf
键访问配置键。
以下是如何访问播放Configuration
对象的权限。
class HomeController @Inject() (configuration: play.api.Configuration) extends Controller {
def foo = Action {
val appSecretString = configuration.underlying.getString("application.secret")
//do something with app secret
Ok(appSecretString) //app secret should not be exposed, just trying to show it on browser, but do not do this in production
}
}