eclipse远程debug

当通过配置tomcat的server.xml文件进行项目部署,而非在eclipse中的server部署运行项目时,如果想要使用eclipse的debug功能,可通过下面方法实现:


在tomcat的bin目录下找到startup.bat,右键--->编辑,在文档中加入下列语句:

SET JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n 

如下图

eclipse远程debug

其中address=8787为设置监听端口,可修改为任意未被占用的端口。

设置好后,启动tomcat,在eclipse中右键要debug的项目,点击Debug As--->Debug Configurations

eclipse远程debug

点击Remote Java Application,Host为tomcat所在IP,Port为调试端口,填写在tomcat中配置的监听端口8787,点击Apply--->Debug,此时如果已在项目中设置好断点,当项目运行到断点位置,eclipse会提示进入debug模式。