項目開發的時候能做斷點就最好啦~而eclipse在這點上是比不上myeclipse的
那麼是不是說我們就不能斷點了呢?現在的項目裡同事用到了斷點我就理所當然也要用啦`在設定的過程中發現一些問題記錄下來!
步驟:
1. 用編譯器開啟weblogic項目目錄下的startWebLogic.cmd ,在裡面加上這句:
set JAVA_OPTIONS=%JAVA_OPTIONS% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n
2.在eclipse裡面
項目名上右鍵-DeBug As-DeBug configurations...-選擇Remote Java Application下你的項目-設定connect Properties下為: localhost 8888,這個port對應的是上面的address.
3.啟動伺服器,在項目名上右鍵Debug As-DeBug configurations...-點擊DeBug按鈕!
然後理論上是可以斷點的了!
PS:可是我這裡報錯:
"Unable to install breakpoint due to missing line number attributes,Modify compiler options to generate line number attributes"
遇到這個錯誤時找到的解答方案匯總:
1、使用Ant編譯時間,未開啟debug開關,在寫javac 任務時確認debug=true,否則不能調試。THe settings for the eclipse compiler don't affect the ant build and even if you launch the ant build from within eclipse. ant controls it's own compiler settings.you can tell ant to generate debugging info like this 'javac ... debug="true".../>
2、編譯器的設定問題,window->preferences->java->Compiler在compiler起始頁,classfile Generation地區中確認已經勾選了All line number attributes to generated class files。如果已經勾選,從新來一下再Apply一下。或者從項目層次進行設定,項目屬性->java compiler同樣在起始頁,確定已經勾選
Eclipse報的這個錯,無非就這兩個原因造成的
第一點是eclipse預設的,不需要怎麼改!第二點就是ant部署的時候編譯java檔案沒有debug="true"的屬性!
加上後重新編譯部署啟動伺服器,點擊debug,運行項目,就可以正常斷點調試了!