博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
idea14远程调试linux下的tomcat
阅读量:5253 次
发布时间:2019-06-14

本文共 3017 字,大约阅读时间需要 10 分钟。

进入到idea的tomcat的run/debug配置,新建个remote tomcat,然后填写相关信息,如上图(注意远程调试端口)。

再选择Startup/Connection,如下图所示:

到此,idea已经配置好了,接下来将图上说的那段拷贝到远程的tomcat的catalina.sh文件中。

登陆到远程服务器,进入到tomcat的bin目录下,vi打开catalina.sh文件:

找到第一个JAVA_OPTS,添加:

JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,address=54531,suspend=n,server=y"或者

CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=54531,suspend=n,server=y"

填一个即可。

重启下tomcat。

netstat -an | grep 55555,查看下55555端口是否打开,打开说民设置成功。

这样既可以使用idea远程调试了。

另外最好的方式就是不要去改动默认的sh文件,那就是自己写的debug.sh

将startup.sh拷贝一份,改名为debug.sh.

打开,内容如下:

#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
# -----------------------------------------------------------------------------
# Better OS/400 detection: see Bugzilla 31132
os400=false
case "`uname`" in
OS400*) os400=true;;
esac
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done
PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh
# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
    echo "Cannot find $PRGDIR/$EXECUTABLE"
    echo "The file is absent or does not have execute permission"
    echo "This file is needed to run this program"
    exit 1
  fi
fi
export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=55555,suspend=n,server=y"
exec "$PRGDIR"/"$EXECUTABLE" start "$@"

 增加红色部分即可。

root@×××:/usr/local/tomcat/bin# sh debug.sh

Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/lib/jdk/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
root@×××:/usr/local/tomcat/bin# netstat -ano|grep 55555
tcp        0      0 0.0.0.0:55555           0.0.0.0:*               LISTEN      off (0.00/0/0)
root@×××:/usr/local/tomcat/bin#
如果按上面步骤执行后,看见设置的端口已经被监听,说明配置成功。

 

转载于:https://www.cnblogs.com/jecyhw/p/4359328.html

你可能感兴趣的文章
RCNN--目标检测
查看>>
北航公开课 演讲与口才1-口才概述
查看>>
BAPI_GOODSMVT_CANCEL物料凭证完全…
查看>>
Thinkphp 生成的验证码不显示问题解决
查看>>
Sql获取数据集中各类型中的最大值(最新值)
查看>>
Xcode:只修改 Bundle Identifier,不修改项目名
查看>>
学习布局中
查看>>
WPF之路五:wpf 隐藏与显示 Visibility
查看>>
XMU 1611 刘备闯三国之卖草鞋 【贪心】
查看>>
hdu 1009 贪心入门
查看>>
使用git克隆指定分支的代码
查看>>
iOS开发拓展篇—蓝牙之CoreBlueTooth(BLE)
查看>>
计算结构体的大小
查看>>
[JSOI 2015] 子集选取
查看>>
asp.net引用用户控件
查看>>
Django之CRM项目Day6-公私户转换问题解决 班主任功能
查看>>
Matlab实现加性高斯白噪声信道(AWGN)下的digital调制格式识别分类
查看>>
POCO C++库学习和分析 -- Foundation库的结构
查看>>
POSIX 线程详解(经典必看)
查看>>
http authentication
查看>>