如何使用sbt的单个命令运行我的项目?我试过了
sbt run src/main/resources/mydata.txt
添加后
mainClass in (Compile, run) := Some("com.mywebsite.MyExample")
mainClass in (Compile, packageBin) := Some("com.mywebsite.MyExample")
到build.sbt,但我得到了
[error] (run-main-0) java.lang.ArrayIndexOutOfBoundsException: 0
java.lang.ArrayIndexOutOfBoundsException: 0
at com.mywebsite.MyExample$.main(MyExample.scala:17)
at com.mywebsite.MyExample.main(MyExample.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
显然,这个论点没有找到我在main方法中调用args(0)
的方法。那么我做错了什么,我该怎么做呢?
答案 0 :(得分:4)
sbt"运行src / main / resources / mydata.txt"