How to make the debugging in playframework in Inte

2019-01-16 08:27发布

Here we have a link

http://www.playframework.org/documentation/1.0.1/ide

about how to configure playframework to be working with different IDEs. There they say a couple of words about debugging, but it is not clear - how can I perform the debugging? If I put a break-point, let's say in my Model's constructor class, then how and what I should launch to initialize debugging? I use IntelliJ Idea.

For example when I use Jboss, or Tomcat, there is an option in the IDE within those servers to run them in debug mode or "normal" mode. But how to work with Play Framework in this context? Should I configure remote debugging somehow?

9条回答
你好瞎i
2楼-- · 2019-01-16 08:49

If its a play project, from the command line :

play debug

If its a SBT play project from the command line :

 sbt -jvm-debug 9999 run

debug port is 9999 by default

now create a remote configuration

in IntelliJ :

Go to "edit run configurations"

enter image description here

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

enter image description here

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

查看更多
Ridiculous、
3楼-- · 2019-01-16 08:51

my fix was: open the "Run/Debug Configurations" dialog, then change the "working directory" to the project directory.

查看更多
倾城 Initia
4楼-- · 2019-01-16 08:54

I had a similar problem.

play (cloned from github at 2011-08-28) and intellij 10.5

SEVERE: Cannot read application.conf

my fix was: -Dapplication.path=. (without "")

to set -Djavaagent=... was no longer necessary on my box.

查看更多
祖国的老花朵
5楼-- · 2019-01-16 08:59

Most convenient way to run/debug applications in intellij IDEA is the following.

Menu command: Run -> Edit Configuration!

Edit configuration

Add new configuration -> Application

Then fill up the fields:

Main class:

play.server.Server

VM Parameters:

-Dapplication.path=.

You should have something similar:

configuration screen

If you did it correctly, then you can run and stop your app right from IDE

EDIT for Play! 2

Play 2 has good documentation for debugging. So go read it. But if you want to investigate run/debug buttons method - read further.

It is different for Play 2.

Settings:

Main class:

play.core.server.NettyServer or play.core.server.ProdServerStart

VM Parameters:

-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999 -Dapplication.path=.

You still can debug your application by pressing debug button but I have not figured out some issues:

  • It always starts in PROD mode, so you can't make hot code changes.

  • RUNNING_PID. There is an error when you restart your debugging session saying that you have to delete this file.

查看更多
闹够了就滚
6楼-- · 2019-01-16 09:07

I had to change this line in my build.sbt from:

fork in run := true

to

fork in run := false

for the breakpoints to work in IntelliJ IDEA 15.0 with the Play 2 App run configuration.

查看更多
Fickle 薄情
7楼-- · 2019-01-16 09:10

In Play 2, simply do the following:

  • From the shell, run play debug
  • You'll be dropped into the debug console. Type run and hit enter.
  • Then create a Remote configuration in IntelliJ IDEA set up for "localhost" and 9999.
  • Start the new configuration
查看更多
登录 后发表回答