【发布时间】:2014-07-02 07:42:09
【问题描述】:
我尝试在“build.sbt”中设置一些系统属性,然后在我的 scala 应用程序中读取它。
在build.sbt:
name := "hello"
version := "1.0"
scalaVersion := "2.11.0"
fork := true
javaOptions := Seq("-Daaa=bbb")
注意我设置了aaa=bbb。以下是我的scala代码:
在src/main/scala/hello.scala:
object Hello {
def main(args:Array[String]) {
println("hello, world")
println(System.getProperty("aaa"))
println("==========")
}
}
然后我运行:
$ sbt
$ console
$ Hello.main(null)
但它会打印:
hello, world
null
==========
你可以看到它仍然是null。正确的做法是什么?
【问题讨论】:
标签: scala sbt system-properties