IntelliJ IDEA Debugger isn't working on a Grails Project

后端 未结 11 1801
孤独总比滥情好
孤独总比滥情好 2020-12-07 22:45

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 brea

11条回答
  •  爱一瞬间的悲伤
    2020-12-07 23:26

    Since Grails 2.3, forked execution for several Grails commands (e.g. run-app, test-app) was introduced. If you just debug a Grails application from IntelliJ IDEA, the GrailsStarter process will be started with debug options on. The output on the IDEA console will be:

    /usr/lib/jvm/default-java/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:59935,suspend=y,server=n [...] /opt/idea-IU-133.330/lib/idea_rt.jar org.codehaus.groovy.grails.cli.support.GrailsStarter [...] run-app Connected to the target VM, address: '127.0.0.1:59935', transport: 'socket'
    

    The application itself will be started in a separate process named ForkedTomcatServer. This is where your code runs and where your debugger should actually connect to.

    To accomplish that, set debug: true in BuildConfig.groovy at the run configuration of grails.project.fork. Just run Grails now from IDEA (do not debug) and you will see the following line in the console when the application is ready to serve HTTP requests:

    Listening for transport dt_socket at address: 5005
    

    This is where you want to direct a separate remote run configuration to. As soon as your remote debugger connected, issue a HTTP request and debugging will work.

    You can also disable forked execution for compile/test/run/war/console Grails commands entirely by setting the value associated with the command entry in grails.project.fork to false. But then you will lose the benefits for forked execution added in Grails 2.3.

提交回复
热议问题