在IntelliJ IDEA中调试SBT项目。

时间:2023-01-18 09:08:38

I have a SBT project

我有一个SBT项目。

in this project i have a sub play project and other projects

在这个项目中,我有一个子游戏项目和其他项目。

example from my build file :

我的构建文件示例:

 lazy val subProj1 = Project(id = "sub-proj-1", base = file("sub1"))
.settings(...)...

 lazy val subProjPlay =  play.Project("play-proj", 1.0 , path = file("web"))

need to debug the play server from IntelliJ IDEA.

需要从IntelliJ IDEA调试play server。

To run the project I use sbt run on the command line.

为了运行这个项目,我在命令行上使用了sbt。

How can I debug the project in IDEA?

我如何在IDEA中调试这个项目?

4 个解决方案

#1


24  

I found this to be the easiest solution : (using IntelliJ IDEA )

我发现这是最简单的解决方案(使用IntelliJ IDEA)

in IntelliJ :

在IntelliJ:

Go to "edit run configurations"

转到“编辑运行配置”

在IntelliJ IDEA中调试SBT项目。

Create a new remote configuration (port 9999, all other details leave with default values)

创建一个新的远程配置(端口9999,所有其他细节都保留默认值)

在IntelliJ IDEA中调试SBT项目。

Go back to IntelliJ and run the new debug configuration (don't forget to put a break point)

返回IntelliJ并运行新的调试配置(不要忘记放一个断点)

From command line run :

从命令行运行:

 sbt -jvm-debug 9999 run

#2


6  

The easiest solution.

最简单的解决方案。

  1. Edit Configurations... -> add SBT Task (not Remote task). Specify SBT Task: run.

    编辑配置…->添加SBT任务(不是远程任务)。指定SBT任务:运行。

  2. Run created SBT Task using - 在IntelliJ IDEA中调试SBT项目。 Debug button

    使用- Debug按钮运行创建的SBT任务。

#3


2  

Provided you've Play distribution installed locally, use play debug run on the command line and connect to localhost on the port 9999 in IDEA.

如果您已经在本地安装了发行版,可以在命令行上使用Play debug运行,并在IDEA中连接到端口9999上的localhost。

From Debugging section in Using the Play console in the official Play 2.2.x documentation:

从调试部分到使用游戏控制台的官方游戏2.2。x文档:

You can ask Play to start a JPDA debug port when starting the console. You can then connect using Java debugger. Use the play debug command to do that

在启动控制台时,可以请求Play启动一个JPDA调试端口。然后可以使用Java调试器进行连接。使用play debug命令来执行这个操作。

If however you don't have it (and for a reason don't want to install it), add Remote Run configuration in IDEA that will give you a hint for the command line arguments you should be using when launching SBT, e.g.

如果没有它(出于某种原因,不希望安装它),请在IDEA中添加远程运行配置,它将提示您在启动SBT时应该使用的命令行参数。

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

When you launch SBT that may or may not be as simple as launching SBT jar, just use the above to configure JVM to run in debug mode.

当您启动SBT时,它可能或不像启动SBT jar那样简单,只需使用上面的方法来配置JVM以在调试模式下运行。

#4


1  

IntelliJ IDEA 2016.1.1 && Play Framework 2.5.3

IntelliJ IDEA 2016.1.1 & Play Framework 2.5.3。

For me, no matter how I set(create new Run/Debug Configuration for Play 2 App or SBT Task, specify the debug port, execute in Run or Debug mode) in the IntelliJ IDEA 2016.1.1 Enterprise Edtion, the IDEA can not open the debug port(default 9999), so the debug is impossible.

对于我来说,无论我如何设置(为Play 2 App或SBT任务创建新的运行/调试配置,指定调试端口,在运行或调试模式下执行),在IntelliJ IDEA 2016.1.1 Enterprise Edtion中,这个想法不能打开调试端口(默认9999),所以调试是不可能的。

After disable the sbt-fork-run-plugin(comment it in /project/paly-fork-run.sbt), it works!!!

在禁用sbt-fork-run-plugin(注释it in /project/paly-fork-run.sbt)之后,它就可以工作了!!!

I am newer to Play framework,and have found many bugs...Compare to RoR, it's so hard to learn, to run, to use, to debug...

我更新了游戏框架,发现了很多bug……与RoR相比,要学习、运行、使用、调试……

Below is my steps:

下面是我的步骤:

  1. disable the sbt-fork-run-plugin(comment it in /project/paly-fork-run.sbt)
  2. 禁用sbt-fork-run-plugin(在/项目/paly-fork-run.sbt中注释)。
  3. execute activator -jvm-debug 9999 "run 11111" (I use port 9999 to debug, port 11111 to run my Play project)
  4. 执行activator -jvm-debug 9999“运行11111”(我使用端口9999调试,端口11111运行我的Play项目)
  5. In IDEA, add an new Run/Debug configuration, Choose, set debug port to 9999
  6. 在IDEA中,添加一个新的运行/调试配置,选择,将调试端口设置为9999。
  7. debug the new created configutation
  8. 调试新创建的配置。

#1


24  

I found this to be the easiest solution : (using IntelliJ IDEA )

我发现这是最简单的解决方案(使用IntelliJ IDEA)

in IntelliJ :

在IntelliJ:

Go to "edit run configurations"

转到“编辑运行配置”

在IntelliJ IDEA中调试SBT项目。

Create a new remote configuration (port 9999, all other details leave with default values)

创建一个新的远程配置(端口9999,所有其他细节都保留默认值)

在IntelliJ IDEA中调试SBT项目。

Go back to IntelliJ and run the new debug configuration (don't forget to put a break point)

返回IntelliJ并运行新的调试配置(不要忘记放一个断点)

From command line run :

从命令行运行:

 sbt -jvm-debug 9999 run

#2


6  

The easiest solution.

最简单的解决方案。

  1. Edit Configurations... -> add SBT Task (not Remote task). Specify SBT Task: run.

    编辑配置…->添加SBT任务(不是远程任务)。指定SBT任务:运行。

  2. Run created SBT Task using - 在IntelliJ IDEA中调试SBT项目。 Debug button

    使用- Debug按钮运行创建的SBT任务。

#3


2  

Provided you've Play distribution installed locally, use play debug run on the command line and connect to localhost on the port 9999 in IDEA.

如果您已经在本地安装了发行版,可以在命令行上使用Play debug运行,并在IDEA中连接到端口9999上的localhost。

From Debugging section in Using the Play console in the official Play 2.2.x documentation:

从调试部分到使用游戏控制台的官方游戏2.2。x文档:

You can ask Play to start a JPDA debug port when starting the console. You can then connect using Java debugger. Use the play debug command to do that

在启动控制台时,可以请求Play启动一个JPDA调试端口。然后可以使用Java调试器进行连接。使用play debug命令来执行这个操作。

If however you don't have it (and for a reason don't want to install it), add Remote Run configuration in IDEA that will give you a hint for the command line arguments you should be using when launching SBT, e.g.

如果没有它(出于某种原因,不希望安装它),请在IDEA中添加远程运行配置,它将提示您在启动SBT时应该使用的命令行参数。

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

When you launch SBT that may or may not be as simple as launching SBT jar, just use the above to configure JVM to run in debug mode.

当您启动SBT时,它可能或不像启动SBT jar那样简单,只需使用上面的方法来配置JVM以在调试模式下运行。

#4


1  

IntelliJ IDEA 2016.1.1 && Play Framework 2.5.3

IntelliJ IDEA 2016.1.1 & Play Framework 2.5.3。

For me, no matter how I set(create new Run/Debug Configuration for Play 2 App or SBT Task, specify the debug port, execute in Run or Debug mode) in the IntelliJ IDEA 2016.1.1 Enterprise Edtion, the IDEA can not open the debug port(default 9999), so the debug is impossible.

对于我来说,无论我如何设置(为Play 2 App或SBT任务创建新的运行/调试配置,指定调试端口,在运行或调试模式下执行),在IntelliJ IDEA 2016.1.1 Enterprise Edtion中,这个想法不能打开调试端口(默认9999),所以调试是不可能的。

After disable the sbt-fork-run-plugin(comment it in /project/paly-fork-run.sbt), it works!!!

在禁用sbt-fork-run-plugin(注释it in /project/paly-fork-run.sbt)之后,它就可以工作了!!!

I am newer to Play framework,and have found many bugs...Compare to RoR, it's so hard to learn, to run, to use, to debug...

我更新了游戏框架,发现了很多bug……与RoR相比,要学习、运行、使用、调试……

Below is my steps:

下面是我的步骤:

  1. disable the sbt-fork-run-plugin(comment it in /project/paly-fork-run.sbt)
  2. 禁用sbt-fork-run-plugin(在/项目/paly-fork-run.sbt中注释)。
  3. execute activator -jvm-debug 9999 "run 11111" (I use port 9999 to debug, port 11111 to run my Play project)
  4. 执行activator -jvm-debug 9999“运行11111”(我使用端口9999调试,端口11111运行我的Play项目)
  5. In IDEA, add an new Run/Debug configuration, Choose, set debug port to 9999
  6. 在IDEA中,添加一个新的运行/调试配置,选择,将调试端口设置为9999。
  7. debug the new created configutation
  8. 调试新创建的配置。