How to run Play Framework 2.x in debug mode in Int

2019-01-22 00:04发布

问题:

I want to run Play Framework 2.x in debug mode in IntelliJ IDEA. I searched in the Internet and all results say that you have to use play console.

Is it possible to run in debug mode in IntelliJ IDEA without using play console?

回答1:

You need to use Idea 12+ Ultimate Edition

  • Install Play 2.0 Support, Scala and other required plugins in Idea
  • In command line perform play idea to generate project
  • Open created project in Idea (open, don't import)
  • Go to: Menu > Run > Edit Configurations... > Add New Configuration... > choose Play 2 App
  • In Menu > Run new buttons will appear Debug and Run, first will run app with enabled debbuger.


回答2:

Using activator :

  1. From Terminal (Not intellij terminal), enter command : activator ui
  2. Open your existing app
  3. Choose "Code view & Open in IDE
  4. In Browse Code, click setting icon
  5. Choose Open Project in Intellij IDEA
  6. Generate

  7. Open Intellij IDEA

  8. Open project - browse your app directory
  9. Run - Edit Configuration
  10. Add new configuration - Remote
  11. Add name Setting transport : socket, debugger mode : attach, Host : localhost, port : 9999 module clashpath : your app
  12. Tools - Open Terminal
  13. activator -jvm-debug 9999 run
  14. Run debug
  15. Open browser localhost:9000


回答3:

  1. Open Intellij IDEA
  2. Open project - browse your app directory Run - Edit Configuration
  3. Add new configuration - Play2
  4. Add http://localhost:9000 to url to open option
  5. Add -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M to JVM option
  6. Set Debug port to 9999
  7. Set your debug point and debug your application. Cheers :)

FYI : All of the above fields might filled up already



回答4:

Preparation: Do not use the project creation by activator ui or similar. Just open the project in IntelliJ.

  1. activator -jvm-debug 9999 ~run. The ~ before run enables automatic reloading of generated HTML pages
  2. In IntelliJ:
    1. Run > Edit Configurations...
    2. Select Defaults/Remote
    3. Click on the green + at the upper left corner
    4. Give the name "Play 2"
    5. Ensure that Transport:Socket and Debugger mode:Attach are selected
    6. Type in 9999 as port
    7. Press "OK"
  3. Run > Debug Play 2 (second entry in the list)

Pro hint: Check out the play-auto-refresh plugin to have Chrome automatically reloading on a change.

(based on @ARM's answer)