【问题标题】:Scala / sbt: How to stop at breakpoints in EclipseScala / sbt:如何在 Eclipse 中的断点处停止
【发布时间】:2015-05-16 21:29:08
【问题描述】:

我在使用 sbt 运行测试时尝试调试我的 Scala 应用程序。我在build.sbt 中添加了以下几行:

javaOptions in test ++= Seq(
  "-Xdebug",
  "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8001"
)

我还在 Eclipse 中设置了断点,并为该端口 8001 配置了远程调试器。

从命令行启动测试时,远程调试器正确启动:

Listening for transport dt_socket at address: 8001

但是测试的执行并没有像预期的那样暂停,所以我无法连接远程调试器。相反,测试只是运行。

有什么想法我可能在这里做错了吗?如何在 Eclipse 中使用断点调试 sbt 测试?

【问题讨论】:

  • M 也面临同样的问题

标签: eclipse scala debugging sbt breakpoints


【解决方案1】:

以下内容对我有用(未在测试中测试,但可能以相同的方式工作)。在这个例子中,我使用了一个由 udash-generator (0.3.1) 生成的项目。

$ sbt
> set fork := true
> set javaOptions ++= Seq("-Xdebug",  "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8001")
> run

我使用了 eclipse (Neon with ScalaIDE 4.4.1, Scala 2.11) (sbt eclipse with-source=true) 并在 com.example.rpc.ExposedRpcInterfaces.hello(name: String) 方法中添加了一个断点。

创建了一个运行配置:

启动启动配置(eclipse 调试器)并使用http://localhost:8080/#/rpc 打开浏览器,开始在文本字段中输入内容,eclipse 在断点处停止。

我不确定你有什么不同,因为你似乎也在 fork 一个新的 JVM 进行测试。如果您提供更多详细信息,我可以尝试您的设置。您正在使用哪个测试框架。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-25
    • 1970-01-01
    • 2012-02-16
    • 1970-01-01
    相关资源
    最近更新 更多