pre:
关闭tomcat应用
进入/bin目录打开catalina.sh:
[root@iZwz947 ~]# cd /
[root@iZwz947 /]# cd home/tmc_test/apache-tomcat-test2
[root@iZwz947 apache-tomcat-test2]# cd bin/
[root@iZwz947 bin]# vim catalina.sh
过程可能会报错:(键入回车强制编辑即可)
E325: ATTENTION
Found a swap file by the name ".catalina.sh.swp"
owned by: tmc_test dated: Wed Jan 24 14:40:18 2018
file name: ~tmc/apache-tomcat-7.0.72/bin/catalina.sh
modified: YES
user name: tmc host name: iZwz9aehttqhrnjk0xy4gqZ
process ID: 8390
While opening file "catalina.sh"
dated: Thu Aug 2 17:42:12 2018
NEWER than swap file!
(1) Another program may be editing the same file. If this is the case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r catalina.sh"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".catalina.sh.swp"
to avoid this message.
Swap file ".catalina.sh.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
添加配置,其中address端口值可自定义:
键入i,添加如下配置,再键入:,输入wq!,强制保存退出。
CATALINA_OPTS="$CATALINA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n"
配置IDEA Remote:
键入远程服务器地址Host,以及上面配置的端口号9999至Port,可手动指定模块路径(即你的项目应用),最后点击OK
tip:确保远程部署Tomcat代码与本地代码版本一致,点击Debug(快捷键Ctrl+F5),本地设置断点,访问远程应用时,便会进入断点