IDEA配置Tomcat远程连接

  1. 服务器上环境准备:JAVA环境+Tomcat
  2. 修改tomcat bin目录下的catalina.sh
# vim catalina.sh
# 添加如下内容
# 由于IDEA的JMX默认1099端口,所以我懒得改端口号了
CATALINA_OPTS="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.rmi.port=1099  # 很重要,不加会导致Connection Error错误
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=xx.xx.xx.xx"  # 服务器地址
export CATALINA_OPTS

3. 修改完后记得重启tomcat并在防火墙开放对应端口

firewall-cmd --list-ports # 查看已开放的端口
firewall-cmd --zone=public --add-port=1099/tcp --permanent  # 开放1099端口
firewall-cmd --reload # 重启防火墙