eclipse进行远程调试

1、tomcat在window下。
 
打开%CATALINE_HOME%/bin下的文件catalina.bat,加入下面这行: 
set CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999
其中address=8787是没被使用的端口号。连接方式有两种,为dt_shmem和dt_socket,分别表示本机调试和远程调试。 
2、tomcat在linux下。
 
      在tomcat的 bin /catalina.sh文件的正文的第一行添加: 
 
declare -x CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999" 
 
配置完成tomcat之后,启动tomcat(正常启动方式),可以查看监听端口是否已经监听。
[root@UC100C ~]# netstat -antp | grep 9999
 
Run—>Debug Configurations
然后在eclipse中的debug的参数配置中,添加要调试的项目名称, 
添加要tomcat所在的主机的IP 地址和tomcat 调试的端口号address=9999。 
然后点击debug 按钮,如下图
 
 通过正常的访问方式(http://远程IP:8080/index.jsp),进行代码的调试工作.
 
 
注意:debug时出现如下错误
Failed to connect to remote VM Connection Refuse
 
解决方案:点击下图中的左数第5个按钮,"disconnect"
 
 
 
 
 
 
 
posted @ 2017-06-20 10:32  .码头  阅读(133)  评论(0)    收藏  举报