Execute Groovy Script
Groovy itself can naturally support Java code, so DebugTools can write Groovy code and run it based on the attached application.
Position
ToolsWindow
Click the toolbar on the right side of Idea to wake up the DebugTools window. Click
on the left to open the Groovy console.
Right-click Menu
In the Idea main window, invoke the right-click menu and click the Groovy Console
button to open the console.
Write
After clicking the Groovy controller, a console.groovy
file will be created in Idea -> Project -> Scratches and Consoles -> Debug Tools Plugins -> groovy
, where you can write Groovy code and run it.
Write the Groovy code to run. You can click the complete example code below to view it.
Why create a file?
Convenient. When writing, idea can provide groovy code prompts, and can also prompt the code according to your current project.
Run
In the console.groovy
file, invoke the right-click menu and click the Run 'console.groovy' With Debug Tools
button. DebugTools will run the script with the attached application.
Result
The running results will be displayed in a pop-up at the bottom, and the toString and debug methods are provided for viewing.