Every new version of Grails brings some enhancements, and challenges on developer side too. Starting Grails 2.3.x, we had to change our approach to use debugger with our application, and with Grails 3.x coming out, we need to change approach to use debugger again.
As Grails now uses Spring Boot and Gradle, we have to hook into bootRun gradle task that gets added by Spring Boot Gradle plugin. We can customize it by adding this task to build.gradle file, as follows:
addResources = false // We can set it to true if we would like to reload src/main/resources
jvmArgs = ["-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"]
Now follow the steps below:
- Add a remote configuration inside your IDE that would attach your debugger to that port.
- Go to terminal, execute grails run-app and wait for prompt that says Listening for transport dt_socket at address: 5005.
- Now just hit debug toolbar symbol on your IDE.
You’re again debugging your Grails application!