1 建立一个remote 项目
2 ip 填入远程的机器
3 端口进行查看 ,catalina.sh
4 选择自己的模块;
下面表示成功
参数解释
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787
dt_socket:使用的通信方式
server:是主动连接调试器还是作为服务器等待调试器连接
suspend:是否在启动JVM时就暂停,并等待调试器连接
address:地址和端口,地址可以省略,两者用冒号分隔
Before Java 5.0, use -Xdebug and -Xrunjdwp arguments. These options will still work in later versions, but but it will run in interpreted mode instead of JIT, which will be slower.
From Java 5.0, it is better to use the -agentlib:jdwp single option:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044
Options on -Xrunjdwp or agentlib:jdwp arguments are :
transport=dt_socket : means the way used to connect to JVM (socket is a good choice, it can be used to debug a distant computer)
address=8000 : TCP/IP port exposed, to connect from the debugger,
suspend=y : if 'y', tell the JVM to wait until debugger is attached to begin execution, otherwise (if 'n'), starts execution right away.
该答案解释了,使用-Xdebug方式,主要是在交互模式下适用,它在性能上会弱于使用-agentlib方式。
同时,该答案还解释了相应的三个参数:
transport:有两种形式,分别是socket和shared memory,需要跨机器,只能用socket
address:端口号,这里采用的是tcp协议。我们可以使用
cat /etc/services | grep '8000'
来查看该端口是否开启
suspend:如果是y,则需要等B机器上的debugger开启后,程序才会开始运行。否则,程序启动时候不会挂起,直接运行。
java -Xrunjdwp:transport=dt_socket,server=y,address=8000 myApp
This command:
-
-
Listens for a socket connection on port 8000.
-
Suspends this VM before main class loads (suspend=y by default).
-
Once the debugger application connects, it can send a JDWP command to resume the VM.
-