我们无法运行主类。我们使用sbt 13.2来对付scala 2.9.3
下面是build.sbt中的条目:
mainClass in (Compile,run) := Some("com.mycompany.swlab.sparkpoc.sql.DbPing")
让我们执行"sbt run":
C:appssimplews>sbt run
"sbt13"
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
[info] Loading project definition from C:appssimplewsproject
[info] Set current project to websocket-simple (in build file:/C:/apps/simplews/)
java.lang.RuntimeException: No main class detected.
at scala.sys.package$.error(package.scala:27)
这是源文件。注意,它是一个具有main()方法的对象。所以我们应该能够执行它。
package com.mycompany.swlab.sparkpoc.sql
import org.apache.log4j.Logger
object DbPing {
import java.sql.{DriverManager, Connection}
def main(args: Array[String]) {
我还尝试提供特定的类运行如下:
> run com.mycompany.swlab.sparkpoc.sql.DB org.apache.hadoop.hive.jdbc.HiveDriver jdbc:hive://localhost:10000/default "" ""
下面是完整的输出
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
[info] Loading project definition from C:appssimplewsproject
[info] Set current project to websocket-simple (in build file:/C:/apps/simplews/)
> run com.mycompany.swlab.sparkpoc.sql.DB org.apache.hadoop.hive.jdbc.HiveDriver jdbc:hive://localhost:10000/default "" ""
java.lang.RuntimeException: No main class detected.
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last root/*:run for the full output.
[error] (root/*:run) No main class detected.
[error] Total time: 0 s, completed May 27, 2014 9:13:55 PM
问题是一个损坏的项目/Build.scala。我恢复到一个简单的构建。