在IDEA中debug play application

在IDEA中debug play application

启动Play Application的时候,你可以通过activator -jvm-debug <port>要求Play额外打开一个JPDA debug port。

sbt或者activator都是一样的。

jqin:play-api-demo jqin$ sbt -jvm-debug 9999
Listening for transport dt_socket at address: 9999
[info] Loading project definition from /Users/jqin/Juli/play-api-demo/project
[info] Set current project to play-api-demo (in build file:/Users/jqin/Juli/play-api-demo/)
[play-api-demo] $

这时候运行run

[play-api-demo] $ run
[info] Updating {file:/Users/jqin/Juli/play-api-demo/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.

--- (Running the application, auto-reloading is enabled) ---

[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

然后打开IDEA(community edition或者ultimate edition无所谓),打开想要debug的项目(play-api-demo),新建一个Remote debug configuration

New Debug Configuration in IDEA

在Port中填上上面activator -jvm-debug <port>中用到的port,本例中为9999

Debug Port

其他都不用改,点Debug即可,这时候IDEA应该会自动打开debug窗口,并显示

Connected to the target VM, address: 'localhost:9999', transport: 'socket'

现在就开始可以设置break point,进行debug了,happy debugging!

(本文系原创,欢迎转载,请注明出处)



Jie

Written by


全职码农,兼职吃货

Updated