我的pom.xml中包含以下内容:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
</args>
</configuration>
</plugin>
我的主要对象是:
object App {
def main(args: Array[String]) {
args.foreach(println)
}
}
它打印:
$ mvn scala:run -DaddArgs='hello|world'
[...]
-unchecked
-deprecation
hello
world
为什么?前两个旨在用作编译器参数(它们实际上是这样工作的),我不想在程序中看到它们!
我该怎么做才能避免这种行为?
最佳答案
如果要尝试使用sbt,请在项目根目录中添加一个简单的build.sbt
:
name := "test"
version := "0.1-SNAPSHOT"
scalaVersion := "2.9.1"
然后你可以运行它
% xsbt
> run Hello World
...
Hello
World
关于scala - 为什么将scala编译器参数传递给我的程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8200863/