Я установил режим разработки в сервлете scalatra на значение свойства config / system
object AppEnv {
private val cloader = getClass.getClassLoader
val PRODUCTION = "production".intern
val DEVELOPMENT = "development".intern
val STAGING = "staging".intern
val TEST = "test".intern
lazy val environment = readEnvironmentKey(println _)
def isProduction = isEnvironment(PRODUCTION)
def isDevelopment = isEnvironment(DEVELOPMENT)
def isStaging = isEnvironment(STAGING)
def isTest = isEnvironment(TEST)
def isEnvironment(env: String) = environment.toLowerCase(Locale.ENGLISH) == env.toLowerCase(Locale.ENGLISH)
def readEnvironmentKey(failWith: String ⇒ Unit = _ ⇒ null) = {
(ep("BACKCHAT_MODE") orElse sp("backchat.mode")) getOrElse {
val inferred = "development"
failWith("no environment found, defaulting to: " + inferred)
inferred
}
}
private def sp(key: String) = {
val s = System.getProperty(key)
if (s != null && s.trim.nonEmpty) Some(s) else None
}
private def ep(key: String) = {
val s = System.getenv(key)
if (s != null && s.trim.nonEmpty) Some(s) else None
}
}
trait ApplicationModes extends ScalatraKernel {
override def environment: String = AppEnv.environment
override def isDevelopmentMode = environment != AppEnv.PRODUCTION && environment != AppEnv.STAGING
}
Scalatra также позволяет использовать свойство System для установки этого режима, вы можете прочитать это свойство и получитьаналогичные результаты.-Dorg.scalatra.environment = развитие