gpt4 book ai didi

command-line - sbt 如何在多个可执行文件时传递命令行参数

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

我的项目有几个可执行文件。我们如何使用提供的命令行参数 运行其中一个 ?在尝试包含来自 sbt run 的 args 后,它们将被忽略,而是列出了可用 main 的菜单:

C:\apps\simpleakka>sbt run "com.mycompany.sparkpoc.hbase.HBasePop spark://localhost:7088 localhost:2181 1000 100"
[info] Loading project definition from C:\apps\simpleakka\project
[info] Set current project to simpleakka (in build file:/C:/apps/simpleakka/)

Multiple main classes detected, select one to run:

[1] com.mycompany.sparkpoc.LCS
[2] com.mycompany.sparkpoc.rdd.HBaseMR
[3] org.apache.spark.examples.HwHBaseTest
[4] com.mycompany.sparkpoc.rdd.HBaseMROld
[5] com.mycompany.sparkpoc.HBaseTest
[6] com.mycompany.sparkpoc.SocketServer
[7] com.mycompany.sparkpoc.hbase.HBasePop

但是通过选择七个选项之一,命令行参数会丢失:
Enter number:

Invalid number: java.lang.NumberFormatException: For input string: ""
java.lang.RuntimeException: No main class detected.
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) No main class detected.
[error] Total time: 3 s, completed Jun 25, 2014 6:12:07 PM

最佳答案

如果你想运行一个特定的主类,你可以使用 runMain ,并且要传递命令行参数,你必须在主类名之后指定它们。

> help runMain
Runs the main class selected by the first argument, passing the remaining arguments to the main method.

例如
> runMain sample.hello.Main firstArg secondArg thirdArg

关于command-line - sbt 如何在多个可执行文件时传递命令行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24421082/

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