Comprehensive Guide to Debugging in IntelliJ IDEA
This article provides a detailed tutorial on using IntelliJ IDEA's debug mode, covering basic usage, shortcut keys, variable inspection, expression evaluation, smart step‑into, conditional breakpoints, multithreaded debugging, drop frame, force return, and JRebel activation for efficient Java development.
一、Debug开篇
首先看下IDEA中Debug模式下的界面。如下是在IDEA中启动Debug模式,进入断点后的界面,标注了8个主要区域,包括启动按钮、断点、Debug窗口、调试按钮、服务按钮、方法调用栈、Variables 和 Watches。
二、基本用法&快捷键
Debug调试的功能主要对应图一中4和5两组按钮,第一组包括 Run、Debug、Step Over (F8)、Step Into (F7)、Force Step Into (Alt+Shift+F7)、Step Out (Shift+F8)、Drop Frame、Run to Cursor (Alt+F9) 和 Evaluate Expression (Alt+F8)。第二组包括 Rerun, Update, Resume Program (F9), Pause Program, Stop, View Breakpoints (Ctrl+Shift+F8), Mute Breakpoints 等。
Show Execution Point (Alt + F10):跳转到当前代码执行行。
> Step Over (F8):逐行执行但不进入方法。
> Step Into (F7):进入当前行的方法内部。
> Force Step Into (Alt + Shift + F7):强制进入任何方法。
> Step Out (Shift + F8):退出当前方法返回调用处。
> Drop Frame:回退断点。
> Run to Cursor (Alt + F9):运行至光标所在行。
> Evaluate Expression (Alt + F8):计算表达式。
三、变量查看
在Debug过程中可以通过参数行旁的值、光标悬停、Variables 窗口、Watches 区以及拖拽方式查看变量。
四、计算表达式
使用 Evaluate Expression (Alt+F8) 可以在调试时直接计算任意表达式的值并修改变量。
五、智能步入
Smart Step Into (Shift+F7) 可以在一行包含多个方法调用时选择具体要进入的方法。
六、断点条件设置
可以在断点上右键设置条件,仅在满足条件时停下;通过 View Breakpoints (Ctrl+Shift+F8) 查看并编辑所有断点的条件、日志和过滤器。
七、多线程调试
默认 Debug 时阻塞所有线程,可在 View Breakpoints 中将 Thread 选项设为默认,以便在多线程环境下切换调试线程。
八、回退断点
通过 Drop Frame 按钮或在调用栈上右键选择 Drop Frame 可以回退到上一个方法调用点,但只能回退执行流程,不能恢复已改变的对象状态。
九、中断Debug
使用 Force Return 可以强制返回指定值,立即结束当前方法的执行,避免后续代码运行。
十、附:JRebel激活
介绍了获取 JRebel 永久激活码的非官方方式,包括使用 Facebook/Twitter 账号登录 https://my.jrebel.com/ 并在插件设置中填写激活码。
Code Ape Tech Column
Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.