`
wusuoya
  • 浏览: 629399 次
  • 性别: Icon_minigender_2
  • 来自: 成都
社区版块
存档分类
最新评论

使用 intellij idea 进行远程调试

阅读更多

以前都是很土得打 log ,发现一篇关于 java 调试器架构 ,以及 eclipse 上使用 的文章,在常用的 intellij idea 以及 tomcat 上调试成功,结合调用堆栈希望可以加快 ``how tomcat works`` 读书进度。

 原理: http://blog.csdn.net/alli0968/article/details/42176721

1. tomcat 7.0.5 启动支持调试

 

新建文件 setenv.bat

 

Java代码  收藏代码
  1. SET CATALINA_OPTS=-server -Xdebug -Xnoagent   
  2. -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000  

 

 放入 tomcat 下 bin/ 中(和 startup.bat)同级。

 

2. 点击 startup.bat 启动,控制台输出调试支持日志表示成功配置:

 

Java代码  收藏代码
  1. Listening for transport dt_socket at address: 8000  

 

3. idea remote debug 配置

 

打开已有的 web 类型项目,设置运行配置

 

 

找到 remote 子项,选择新增配置

 

 

输入项目名称,端口设置 tomcat 配置的 8000,并选择源码所在模块,调试模式为 attach

 

 

 

 

点击 ok 关闭设置窗口

 

4. 在源码上设置断点后,点击调试按钮

 

 

 

 

 

 

调试窗口输出

 

Java代码  收藏代码
  1. Connected to the target VM, address: 'localhost:8000', transport: 'socket'  

 

表示正常连上了远端(localhost)服务器。

 

5.启动调试

 

使用浏览器访问对应服务器应用,启动调试,运行到客户端断点时,就可以查看当前帧变量与堆栈信息了:

 

 

 

再进一步关联 tomcat 源码 则可以了解到请求在 servlet 容器中的一系列转发过程了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics