使用 simple-build-tool (sbt) 和 IntelliJ 调试 Scala 代码 [英] Debugging Scala code with simple-build-tool (sbt) and IntelliJ

查看:32
本文介绍了使用 simple-build-tool (sbt) 和 IntelliJ 调试 Scala 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 IntelliJ 的内置调试器调试由 sbt 管理的 Scala 代码的最简单方法是什么?"RunningSbt" from sbt's google code site 的文档列出了命令用于运行项目或测试的主类,但似乎没有用于调试的命令.

What's the easiest way to debug Scala code managed by sbt using IntelliJ's built-in debugger? The documentation from "RunningSbt" from sbt's google code site lists commands for running the main class for a project or the tests, but there seem to be no commands for debugging.

后续问题:在使用 sbt 的 jetty-run 命令时,将 IntelliJ 的调试器附加到 Jetty 的最简单方法是什么?

Follow-up question: what's the easiest way to attach IntelliJ's debugger to Jetty when using sbt's jetty-run command?

推荐答案

对于 IntelliJ 中的普通调试,您可以按照通常的方式使用应用程序运行/调试配置,无论您是否使用 sbt 编译代码.

For ordinary debugging in IntelliJ, you can use an Application run/debug configuration in the usual way, regardless of whether you're using sbt to compile your code.

要连接到在 Jetty 中运行的应用程序,您需要创建远程调试配置.当您这样做时,IntelliJ 将为您提供一组用于运行远程 JVM 的命令行参数——类似于

To connect to your application running in Jetty, you'll need to create a Remote debug configuration. When you do so, IntelliJ will give you a set of command line arguments for running the remote JVM -- something like

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005

使用这些参数启动 sbt,然后执行 jetty-run.最后,在 IntelliJ 中启动您的远程调试配置.这个主题可能有用.

Launch sbt with these arguments and then execute jetty-run. Finally, launch your remote debug configuration in IntelliJ. This thread might be useful.

这篇关于使用 simple-build-tool (sbt) 和 IntelliJ 调试 Scala 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆