当使用sbt run时,如下所示:

sbt "project epa-recon" "run"


我们看到找到两个主要的:

[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list

Multiple main classes detected, select one to run:

 [1] com.lash.epa.recon.EPAReconApp
 [2] com.lash.epa.recon.EPAReconApp47D


因此,我们应该可以使用runMain ..不?

sbt "project epa-recon" "runMain com.lash.epa.recon.EPAReconApp"


好..没有..

[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
java.lang.RuntimeException: No main class detected.
    at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last epa-recon/compile:runMain for the full output.
[error] (epa-recon/compile:runMain) No main class detected.


这些消息是矛盾的。那么..对这里真正的问题有什么见解?

最佳答案

我只是运行了您在问题中提供的确切语法,所以它起作用了。在Linux上使用sbt 1.2.3。

sbt "project subproject1" "runMain com.myco.SomeClassName"

关于sbt - sbt无法从runMain中找到“主”类,但可以从run中看到它,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38599313/

10-12 22:09