2015-06-17 50 views
1

我寫這篇Scala代碼SBT不會接指定mainClass

package com.abhi 

import java.io.File 

object Main1 { 
    def main(args: Array[String]) : Unit = { 
     println("Main1 Hello World") 
    } 
} 

object Main2 { 
    def main(args: Array[String]) : Unit = { 
     println("Main2 Hello World") 
    } 
} 

這built.sbt文件

name := "Foo" 

version := "1.0" 

scalaVersion := "2.11.6" 

libraryDependencies ++= Seq(
    "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test" 
) 

mainClass:= Some("com.abhi.Main1") 

但是當我運行sbt run還在說

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

Multiple main classes detected, select one to run: 

[1] com.abhi.Main1 
[2] com.abhi.Main2 

Enter number: 

爲什麼它還在問我要選擇哪一個班?選擇主類的build.sb已經指定

回答