【发布时间】:2012-02-16 02:26:28
【问题描述】:
我正在尝试在我的新应用程序中使用 ostrich 作为配置库(以前我曾有过使用它进行运行时统计的积极经验)。但我无法使用自述文件中的代码 sn-p 使其工作。
这是我的代码:
class Boot {
val bootLogger = LoggerFactory.getLogger(this.getClass)//slf4j
val confPath = Option(System.getenv("CONF_FILE"))
//living inside akka-kernel, so there is no access to real args
val args: Array[String] = confPath match {
case Some(path) => Array("-f", path)
case None => Array()
}
bootLogger.info(Class.forName("la.myproject.Config").toString)
val runtime = RuntimeEnvironment(this, args)
val server = runtime.loadRuntimeConfig[Server]()
try {
server.start()
} catch {
case e: Exception =>
bootLogger.error("Server start failed", e)
}
}
这是我的配置:
new la.myproject.Config {
//use the defaults
}
程序成功加载配置类,失败并出现以下错误:
配置文件错误:../../src/main/conf/myproject.scala
com.twitter.util.Eval$CompilerException:编译器异常错误:第 3 行:未找到:值 la
新的 la.myproject.Config {
我猜这是一个类加载问题。但是挖掘消息来源让我不知道为什么会发生这种情况。 Ostrich 和 Eval 实用程序根本不涉及类加载。
【问题讨论】: