Play Framework 2.1: Use play.api.Configuration in Build.scala

后端 未结 1 983
情深已故
情深已故 2020-12-05 05:44

In the top answer to Play Framework 2: Read the application version defined in Build.scala it\'s suggested that the application version number be specified in conf/app

相关标签:
1条回答
  • 2020-12-05 06:34

    I works in 2.1-RC2 if you use typesafe's config library directly, without Play's Configuration wrapper. It's a Java API, so it is used slightly different than described in this answer.

    In project/Build.scala import the library:

    import com.typesafe.config._
    

    and load the configuration from the file manually. Calling resolve() is needed to resolve substitutions.

    val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve()
    
    val appName    = conf.getString("app.name")
    val appVersion = conf.getString("app.version")
    
    0 讨论(0)
提交回复
热议问题