通过Intellij IDEA对tomcat进行远程调试

来源:互联网 发布:miui9修改mac地址 编辑:程序博客网 时间:2024/04/29 23:41

前提

  • intellij idea 14 ultimate
  • linux
  • jdk 1.8
  • tomcat 7.0.x

1. 配置Intellij IDEA

添加配置,选择tomcat Server->Remote

new server

选择startup/connection标签->debug,注意到里面的配置,将其添加到tomcat的启动配置里面

startup/connection

在服务器的$TOMCAT_HOME/bin/catalina.sh中最上面增加:

export JAVA_OPTS='-agentlib:jdwp=transport=dt_socket,address=53013,suspend=n,server=y'

然后重启tomcat

cd $TOMCAT_HOMEbin/shutdown.shbin/startup.sh

设置tomcat要连接的远程机器host和port,host就是服务器的地址(ip或者域名),port就是刚刚添加的port 53013

host/port

完了之后,用Intellij IDEA连接tomcat,选择debug

host/port

然后就看到显示

Connected to the target VM, address: 'www.xxxxxxx.com:51981', transport: 'socket'

host/port

然后就可以像在本机一样,设置断点,然后进行远程调试了

0 0