gpt4 book ai didi

scala - 为什么将scala编译器参数传递给我的程序?

转载 作者:行者123 更新时间:2023-12-02 04:04:57 27 4
gpt4 key购买 nike

我的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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com