IntelliJ IDEA Debugger isn't working on a Grai

2019-01-16 14:24发布

I can't debug my code in Intellij IDEA. When debug mode is active and running, but the breakpoints don't have that "v" checked that represents a valid and stoppable breakpoint.

See the image: http://prntscr.com/1w0owu.

I really search on the web for an answer. What I suppose to do?

11条回答
混吃等死
2楼-- · 2019-01-16 14:26

Try this:

In idea choose Edit configurations from list next to 'run' button. Then add Remote, choose your name and left default remote configuration settings. (port 5005 etc)

Run your app from console by using

grails run-app --debug-fork

In idea, choose your configuration from list and hit debug button when console display info:

Listening for transport dt_socket at address: 5005
查看更多
做个烂人
3楼-- · 2019-01-16 14:26

Just three guesses:

Try running run-app, not run-war, both should work, but may be run-war just isn't working.

Or: try debugging remotely from console:

grails -debug run-app and then connect with Remote Debug in Idea.

Or, the last resort: downgrading your project to previous Grails versions could work. Yes, this is really annoying.

Hope this helps.

查看更多
叼着烟拽天下
4楼-- · 2019-01-16 14:27

I tested with intellij latest with Grails 2.3.4 on Mac Os x Lion.

Then I tried Igors's advice and it is working without forked mode.

grails.project.fork = [
    test: false,
    run: false
]

Please check for detail grails documentation

if you want to debug forked mode you should check following blog post explainsvery well.

http://blog.jdriven.com/2013/12/grails-goodness-debugging-app-forked-mode/

查看更多
放荡不羁爱自由
5楼-- · 2019-01-16 14:28

This is a very simple matter with Grails 3 and Idea (2016.1). There's no need to edit any files anymore, as recommended in the other answers.

For some reason, the debug icon in the Idea toolbar is greyed out, so you just have to navigate to your application entry point (the class that has the static void main method that starts the application), click on one of the run arrows in the left-hand gutter and select the Debug option.

From the JetBrains docs:

https://www.jetbrains.com/help/idea/2016.1/getting-started-with-grails-3.html

Debugging Grails 3 Application

IntelliJ IDEA lets you debug your Grails 3 application using Application.groovy.

In the Project tool window, open init directory and right-click the Application.groovy From the drop-down list select Debug Grails:'name' grails3_debug_app You can also use the editor to start the debugging process.

查看更多
祖国的老花朵
6楼-- · 2019-01-16 14:42

Debugging a grails (2.3+) application can be done in two ways.

1. Simple solution: disable debug

edit BuildConfig.groovy:

grails.project.fork = [
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, fork ...
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, fork ...

to

grails.project.fork = [
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, fork ...
    run: false,

Pros:

  • Simple to do (and get on with your development)

Cons:

  • This removes the ability to perform runtime code replacement. This means that if you change code, it will no longer be picked up automatically and you will need to restart the application to see the changes. This can be very time consuming.

2. Involved solution: debug forked runtime

This is a somewhat more complex solution where you attach a debugger to a running grails application. It is described in more detail in this blog post.

After setup you have an extra run configuration that allows you to start up grails in forked mode, and yet another extra run configuration that allows you to debug that forked mode. The catch is that you are required to start both or it does not work.

Pros:

  • You have both debugging and runtime code replacement
  • This does not interfere with starting the application in normal mode. (i.e. you have extra options)

Cons:

  • Setting up takes a little bit of time
  • Starting up in debug mode requires is a more complex two step process (i.e. it takes longer)

Considerations

Solution 2 is mostly superior in the sense that it allows flexibility. I personally don't use debug a lot, so just start in normal mode. When I want to debug, I restart in debug mode.

Solution 1 is strictly better if you need to debug and also need to restart a lot. For instance when you are working on your domain classes or database setup in your BootStrap.groovy.

查看更多
我想做一个坏孩纸
7楼-- · 2019-01-16 14:44

I have tried all mentioned here without success. The only helpful information is here.

In essence you should disable forked execution by adding the following to grails-app/conf/BuildConfig.groovy:

grails.project.fork = [
    test: false,
    run: false
]

Now debugging is available in IntelliJ IDEA Ultimate Edition v.12.1.6 just by ordinary Debug without Remote debugging. Tested on Grails 2.3.1, Java 1.7.0_45, Windows 7 64-bit.

查看更多
登录 后发表回答