How to debug play2 in idea?

2019-04-07 18:34发布

I found some articles on the internet and some discussions on google group, but they don't work any more.

How to do it with the latest play2-RC3 ?

3条回答
smile是对你的礼貌
2楼-- · 2019-04-07 19:03

You can start the play server in debug mode from console [docs], and should be able attach a debugger instance from Idea given that you know the port debugger is listening on.

I haven't use Idea so not sure if it is doable or not. It is fairly easy from netbeans. I suspect, it should be similar from Idea.

EDIT: They have also posted this in their customization guide for IDEs.

查看更多
Luminary・发光体
3楼-- · 2019-04-07 19:06

Go to Run -> DEBUG -> Edit Configurations

use "Remote" Configuration and set the Port to 9999

查看更多
Fickle 薄情
4楼-- · 2019-04-07 19:21

Debugging Play 2.x is very easy with IntelliJ IDEA 12.x, here are the steps you have to do:

Step 1. Enable the Play Framework Support plugin and the Play 2.0 Support plugin in File > Settings > Plugins.

repo image

The generic plugin usually comes with IntelliJ but make sure it's enabled. The Play 2.0 Support plugin can be downloaded by clicking Install Jetbrains plugin.... Simply locate and install the plugin from the list, the latest working version for 12.x is v.0.2.49. (it may prompt that a Scala plugin needs to be installed aswell)

Step 2. Create a new Play app if you haven't or use an existing one

Step 3. Create a new Debug configuration: Run > Edit configurations...

You can click the + icon in the top left corner to add a new configuration. Simply select Play 2 app from the list and give the configuration a name. The default options should be correct but feel free to change them if necessary. When done, click Apply and Ok.

Step 4. Your toolbar should now have a Run icon and a Debug icon enabled.

play run/debug icon

Simply click the green arrow to run the Play application. This is the equivalent of doing play run from the commandline (except without the commandline).
To debug, click the green bug, next the the arrow. This is the equivalent of doing play debug from the commandline.

You will now be able to debug when a breakpoint is encountered.

Notes:

  • Make sure there is only 1 configuration running at a time because Play doesn't like multiple instances running at the same time.
  • If you're having trouble compiling, do a play clean-all and play package on the commandline, this should resolve most problems. If there are further problems, also try play idea from the commandline.
  • Make sure the Play configuration is filled in in your settings. You can do this by going to File > Settings > Play Configuration.

A video of these steps can also be found in this video by James Ward (start at around 1:40 min.).

查看更多
登录 后发表回答