我的应用程序中有6个主要类,我通常只使用其中一个,所以我想通过sbt自动运行它.sbt可以在build.sbt中定义两个键:
// Run Key
val selectMainClass = TaskKey[Option[String]]("select-main-class", "Selects the main class to run.")
val mainClass = TaskKey[Option[String]]("main-class", "Defines the main class for packaging or running.")
Run Code Online (Sandbox Code Playgroud)
所以我定义了它们(示例项目,两个类 - 源目录根目录中的Main1和Main2):
mainClass := Some("Main1")
selectMainClass := Some("Main1")
Run Code Online (Sandbox Code Playgroud)
sbt提示符中的`show main-class'似乎也有效:
[info] Some(Main1)
Run Code Online (Sandbox Code Playgroud)
但是,sbt的run任务仍然促使我进入主要班级.
此外,sbt-revolver无法处理具有异常的多个类java.util.NoSuchElementException: None.get
使用sbt 0.11.2.
我在这做错了什么?
我有一个scalatra servlet:
post("/asdf") {
???
}
Run Code Online (Sandbox Code Playgroud)
我的客户在邮件正文中发送xml,因此我需要从请求中提取原始文本.我如何在scalatra中做到这一点?
我需要启动Akka(2.0)演员系统,发送一些消息,然后等待它做繁重的工作.在那之后,我需要做一些与这些演员无关的事情.
我试图等待所有演员停止使用以下代码:
val system = new ActorSystem("parallelRunners")
val master = system.actorOf(Props[Master])
master ! Start
system.awaitTermination // <-- hangs here
Run Code Online (Sandbox Code Playgroud)
所有演员通过自杀self ! PoisonPill.我究竟做错了什么?
我想对带有孔的复杂(但不是自相交)多边形进行三角测量,以便生成的三角形全部位于多边形内部,完全覆盖该多边形,并遵守Delaunay三角形规则.
显然,我可以为所有点构建Delaunay三角剖分,但是我担心多边形的某些边缘不会被包含在生成的三角剖分中.
那么,这样的三角测量可能吗?如果是,我该怎么办?
以防万一 - 我需要它来构造多边形中轴的近似(我希望它可以通过连接所得三角形的所有圆周点来完成).
我从sbt运行我的scalatest,输出混合起来 - scalatest打印所有测试运行,并对它们发表评论,并在中间某处打印统计信息:
> test
[info] Compiling 1 Scala source to /home/platon/Tor/scala-dojo-02/target/scala-2.9.1/classes...
[info] FunsWithListsTests:
[info] - should return list of labels
[info] - should return the average rating of games belonging to Zenga
[info] - should return the total ratings of all games
[info] - should return the total ratings of EA games *** FAILED ***
[info] 0 did not equal 170 (FunsWithListsTests.scala:35)
[error] Failed: : Total 8, Failed 5, Errors 0, Passed 3, Skipped 0
[info] - should increase …Run Code Online (Sandbox Code Playgroud) 我想从scala运行我的进程,修改了几个环境变量.例如:
Seq("bash","echo $asdf") !
Run Code Online (Sandbox Code Playgroud)
和$ asdf设置为某个值.有没有办法从scala做到这一点?
编辑:
到目前为止我最接近它:
val pb = new java.lang.ProcessBuilder("bash","echo $asdf")
pb.environment.put("asdf","value") }
val p = pb.start()
io.Source.fromInputStream(p.getInputStream).getLines.toList.foreach(println)
p.waitFor()
Run Code Online (Sandbox Code Playgroud)
但这很难看.
我有Java应用程序,不幸的是,它在一段时间后开始消耗相当大的内存.更复杂的是,它不仅是Java应用程序,也是JavaFX 2应用程序.
我怀疑有一些内存泄漏,甚至可能在底层的JavaFX调用和本机库中.
理想的解决方案是在某个时刻获取所有java对象的转储(使用它们的内存),然后分析该转储.有没有办法实现这个目标?
我偶然发现了以下问题 - 当我创建.jar超过65k条目的文件时,java会抱怨"无效或损坏jarfile".例:
$ # in fresh dir
$ for i in {1..70000}; do touch $i; done
$ jar cf app.jar {1..70000}
$ java -jar app.jar
Error: Invalid or corrupt jarfile app.jar
Run Code Online (Sandbox Code Playgroud)
但如果我使用少量文件,它的工作原理如下:
$ jar cf app.jar {1..60000}
$ java -jar app.jar
no main manifest attribute, in app.jar
Run Code Online (Sandbox Code Playgroud)
我听说旧.zip文件格式有65k文件限制,但Java 7默认情况下应该使用ZIP64.为什么会这样?有办法解决吗?
在类或对象体中,这适用:
def a(s:String) {}
def a(s:Int) {}
Run Code Online (Sandbox Code Playgroud)
但是如果将它放在另一个方法中,它就不会编译:
def something() {
def a(s:String) {}
def a(s:Int) {}
}
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
我试图使用Proguard缩小和混淆我的Scala/Java程序.虽然我只使用scala-library.jar,但一切都很好,但是当我将scala-swing.jar添加到我的罐子中时,我得到以下内容:
Warning: scala.swing.ComboBox: can't find referenced class scala.swing.ComboBox$selection
Warning: scala.swing.ListView: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$: can't find referenced class scala.swing.ListView$selection$items
Warning: scala.swing.ListView$selection$$anon$7: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$Indices: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$items$: can't find referenced class scala.swing.ListView$selection
Run Code Online (Sandbox Code Playgroud)
如果我查看jar,我发现实际上没有这样的文件 - scala.swing.ComboBox$selection$.class而不是scala.swing.ComboBox$selection.class.手动重命名不起作用 - 然后它抱怨该文件包含具有不同名称的类.
那么,scala-swing.jar中的这些非法引用是什么?还是Proguard的一个错误? …