首先以debug模式啟動tomcat,并檔案中設斷點,然後運作,當程式走到斷點處就會轉到debug視圖下
[1]快捷鍵(F8)直接執行程式。
[2]快捷鍵(F5)單步執行程式,遇到方法時進入。
[3]快捷鍵(F6)單步執行程式,遇到方法時跳過。
[4]快捷鍵(F7)單步執行程式,從目前方法跳出。
=====================================
1.Step Into (also F5) 跳入
2.Step Over (also F6) 跳過
3.Step Return (also F7) 執行完目前method,然後return跳出此method
4.step Filter 逐漸過濾 一直執行直到遇到未經過濾的位置或斷點(設定Filter:window-preferences-java-Debug-step Filtering)
5.resume 重新開始執行debug,一直運作直到遇到breakpoint
6.hit count 設定執行次數 适合程式中的for循環(設定 breakpoint view-右鍵hit count)
7.inspect 檢查 運算。執行一個表達式顯示執行值
8.watch 實時地監視變量的變化
9.我們常說的斷點(breakpoints)是指line breakpoints,除了line breakpoints,還有其他的斷點類型:field(watchpoint)breakpoint,method breakpoint,exception breakpoint.
10.field breakpoint 也叫watchpoint(監視點) 當成員變量被讀取或修改時暫挂
11.添加method breakpoint 進入/離開此方法時暫挂(Run-method breakpoint)
12.添加Exception breakpoint 捕抓到Execption時暫挂(待續...)
斷點屬性:
1.hit count 執行多少次數後暫挂 用于循環
2.enable condition 遇到符合你輸入條件(為ture\改變時)就暫挂
3.suspend thread 多線程時暫挂此線程
4.suspend VM 暫挂虛拟機
13.variables 視圖裡的變量可以改變變量值,在variables 視圖選擇變量點選右鍵--change value.一次來進行快速調試。
14.debug 過程中修改了某些code後--〉save&build-->resume-->重新暫挂于斷點
===========================
例如你有如下程式:
public static void main(String args[]) {
MyDate aa = new MyDate();
aa.addDays(day); =============》(1)
System.out.println("www.lovewenzhang.com");=============》(2)
}
public String addDays(int more_days) {
System.out.println("1"); =============》(3)
String result = ""; =============》(4)
System.out.println("2"); =============》(5)
return result;
你在(1)處加斷點,運作到此處時如果Step Into (also F5)為跳入,則接着執行到(3)。再執行Step Over (also F6)執行本行,則執行到(4)。最後執行Step Return (also F7),則跳出addDays方法,跳到(2)