Skip to content

Commit

Permalink
2016-04-25 添加远程调试文章
Browse files Browse the repository at this point in the history
  • Loading branch information
judasn committed Apr 25, 2016
1 parent 80060c6 commit a679884
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
- [31.IntelliJ IDEA 常用快捷键讲解(Win+Linux)](keymap-introduce.md)
- [32.IntelliJ IDEA 常用快捷键讲解(Mac)](keymap-mac-introduce.md)
- [33.IntelliJ IDEA 的 Java 热部署插件 JRebel 安装及使用](jrebel-setup.md)
- [34.本教程总结](this-tutorial-the-end.md)
- [34.IntelliJ IDEA 远程调试](remote-debugging.md)
- [35.本教程总结](this-tutorial-the-end.md)


## 联系(Contact)

Expand Down
3 changes: 2 additions & 1 deletion TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
- [31.IntelliJ IDEA 常用快捷键讲解(Win+Linux)](keymap-introduce.md)
- [32.IntelliJ IDEA 常用快捷键讲解(Mac)](keymap-mac-introduce.md)
- [33.IntelliJ IDEA 的 Java 热部署插件 JRebel 安装及使用](jrebel-setup.md)
- [34.本教程总结](this-tutorial-the-end.md)
- [34.IntelliJ IDEA 远程调试](remote-debugging.md)
- [35.本教程总结](this-tutorial-the-end.md)
Binary file added images/remote-debugging-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/remote-debugging-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/remote-debugging-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/remote-debugging-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/remote-debugging-5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions remote-debugging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# IntelliJ IDEA 远程调试 Tomcat

## 准备工作

- 明确远程服务器的 IP 地址,比如我是:192.168.92.128
- 关掉服务器防火墙:`service iptables stop`

## 本地 Remote Server 配置

- 添加 Remote Server,如下图
- ![本地 Tomcat 配置](images/remote-debugging-1.jpg)
- 复制 Remote Server 自动生成的 JVM 参数,等下有用,如下图,比如我的是:`-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005`
- 如下图,在 Host 添加服务器的 IP 地址:192.168.92.128。
- ![本地 Tomcat 配置](images/remote-debugging-2.jpg)
- 把刚刚复制参数加个前缀,变成:`export JAVA_OPTS='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'`


## 服务器 Tomcat 配置

- 以 Linux 环境为例
- Tomcat 安装在 /usr/program/tomcat7
- Tomcat 的执行程序:/usr/program/tomcat7/bin/catalina.sh
- 编辑 Tomcat 执行程序:`vim /usr/program/tomcat7/bin/catalina.sh`
- 在该文件的最上面,添加我们刚刚复制的那句话:`export JAVA_OPTS='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'`。
- 如果你的项目有特殊 JVM 参数,那你就把你的那部分参数和这部分参数合并在一起。
- 如下图所示:
- ![远程 Tomcat 配置](images/remote-debugging-3.jpg)


## 开始调试

- 启动服务器 Tomcat
- 启动本地 Remote Server
- 如果可以看到如下图效果,表示已经连接成功了,接下里就是跟往常一样,在本地代码上设置断点,然后你访问远程的地址,触发到该代码自动就会在本地停住。
- ![开始调试](images/remote-debugging-4.jpg)
- 如下图,可以看到调试效果
- ![开始调试](images/remote-debugging-5.jpg)

0 comments on commit a679884

Please sign in to comment.