Accessing the application.conf properties from java class with Play! 2.0

前端 未结 13 2153
一整个雨季
一整个雨季 2020-12-24 10:37

I want to add an object to the Global scope, and in order to construct it I need to pass it a path to a file. I don\'t want to hard code the file path in the source, and so

13条回答
  •  一向
    一向 (楼主)
    2020-12-24 10:51

    Try Play.application().configuration().getString("your.key")

    As noted in the comment (nico_ekito), please use play.Play and not play.api.Play. play.api.Play is for scala controllers (see comment by Marcus biesior Biesioroff)

    Additionally, play uses https://github.com/typesafehub/config under the hood so it can also provide some insights.

提交回复
热议问题