我有scala应用程序,并且使用了使用maven scala插件的pom.xml,我的应用程序使用scala readInt
从命令行读取整数
该项目是在eclipse上构建的,当我使用eclipse运行scala应用程序时,它可以工作
当我尝试使用scala插件运行相同的应用程序时,它会卡住readInt
mvn scala:run -DmainClass=run.readFromConsole
我错过了什么吗?
这是异常追踪
[INFO] Checking for multiple versions of scala
Exception in thread "main" java.io.EOFException: Console has reached end of input
at scala.Console$.readInt(Console.scala:349)
at scala.Predef$.readInt(Predef.scala:296)
at run.readFromConsole$$anonfun$1.apply$mcVI$sp(readFromConsole.scala:6)
at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:141)
at run.readFromConsole$delayedInit$body.apply(readFromConsole.scala:5)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at run.readFromConsole$.main(readFromConsole.scala:3)
at run.readFromConsole.main(readFromConsole.scala)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.929s
[INFO] Finished at: Thu Apr 03 16:42:20 IST 2014
[INFO] Final Memory: 14M/299M
代码
object readFromConsole extends App {
for (i <- 0 to 4) {
println("Console Input " +i+ " " + readInt )
}
}
代码运行正常,使用scalac,scala甚至是eclipse scala应用程序,当我尝试从mvn scala应用程序运行它会抛出错误。
mvn clean compile scala:run -DmainClass=run.readFromConsole