play! with scala 获取配置文件的内容

application.conf 配置文件内容

#custom config:
test.config="test.config.value"

scala中获取

Play.current.configuration.getString("test.config")

view中获取

@play.Play.application().configuration().getString("test.config")

单元测试

package task

import org.specs2.mutable._

import play.api.test._
import play.api.test.Helpers._
import play.api.Play

class ApplicationConfigSpec extends Specification {

  "Get 'test.config' value" should {
    "The 'test.config' value is 'test.config.value'" in {
      running(FakeApplication()) {
        val configValue = Play.current.configuration.getString("test.config").get
        configValue must equalTo("test.config.value")
      }
    }
  }
}



你可能感兴趣的:(play! with scala 获取配置文件的内容)