Can I debug a Grails application with a Text Edito

2019-03-21 14:02发布

问题:

I am getting started with Grails and I watched quite a few videos where the presenters demonstrated Grails 2.X with the command line and a text editor such as textmate.

Here are my 2 questions:

  1. Is it the recommended workflow or most popular one? Or most people use STS?

  2. I enjoy text editors and I would like to know if it is possible to debug a Grails app with Sublime Text 2

Thanks

回答1:

You can debug grails applications outside of an IDE with the bare bones jdb debugger that comes with the JDK. You won't get the typical IDE debugging experience, but something more like a traditional command-line debugger like gdb on Unix.

To get started, run your application with grails -debug instead of grails. You'll see

Listening for transport dt_socket at address: 5005

At this point, run jdb as follows:

jdb -attach localhost:5005

You should be prompted with a prompt like main[1]. Now you can set breakpoints and watches and start your app. For example:

main[1] stop in mypackage.MyController.action()
Deferring breakpoint mypackage.MyController.action().
It will be set after the class is loaded.
main[1] run

When the breakpoint is hit, you can step through the code with step and next, and continue running with cont.