標籤:blank target border 工具列 style
maven 是個好工具,管理起來還是相當方便的,不過說道用 eclipse 來調試,那應該是 eclipse 的遠端偵錯,步驟和各設定如下:
1、工具列 –> Run –>External Tools –>External Tools Configurations,配置如下
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/54/6B/wKioL1SBxquThcN0AAGTY_CGIP4356.jpg" "632" height="339" />
在右側的 environment 的選項卡添加如下變數:
MAVEN_OPTS = -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y
2、Run –> Debug Configurations,設定如下:
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/54/6B/wKioL1SBxqzw-qQXAAG-SbtTV9o471.jpg" "617" height="295" />
在右側 environment 的選項卡添加如下變數(與前面一致,address 為連接埠號碼)
MAVEN_OPTS = -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y
3、重新開啟第一步的設定面板,點擊 Run;開啟第二次設定的面板,點擊Debug,就可以開始調試之旅啦,使用這種方法調試,相對本地的調試,應該會沒有那麼完美,我所知道的就有 display 功能不能用。
另外,在 maven 開發裡會經常遇到,一個工程由工作空間裡好幾個項目組成,在調試過程中,調試各模組的代碼,也是一種常見的需要,具體設定如下:
1、運行 maven 項目時,選擇 Resolve workspace artifacts
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/54/6D/wKiom1SBxh7j5_1kAADUHJsZJVY066.jpg" "421" height="207" />
2、在 Refresh 選項卡裡,勾選 resources upon completion
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/54/6D/wKiom1SBxh-zAWntAACTXE-Ms24158.jpg" "443" height="234" />
3、Source 選項卡添加進工作空間 Workspace
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/54/6B/wKioL1SBxq-gbSvgAAClbBSwuho872.jpg" "479" height="257" />
如此設定,在 調試時,便可順利切換到各個模組代碼中。另外,如果調試時需要看maven依賴的第三方jar包的源碼,可以直接在 jar 包上右鍵下載源碼。
若遇上 JVM_BIND(8080) 的問題,可以使用以下兩個命令解決:
netstat -aon|findstr “8080”
知道對應進程的 pid,再輸入
tasklist|fidstr "pid"
在資源管理員關閉該 pid 進程即可。
maven eclipse 調試那些事