Eclipse remote debugging


  

 I have been using Eclipse. For some reason, the service needs to be uploaded to the server before it can be released normally. When developing functions and BUG positioning, I can only rely on the system output to track. The process needs to be packaged and uploaded many times, which is a waste of time. It is recommended to know the Eclipse remote debugging function, and record the construction process here; first, when packaging the project, enter a breakpoint in the code, then package it normally, upload it to the server, and add -Xdebug -Xrunjdwp to the startup script :transport=dt_socket,address=52002,server=y,suspend=n ;

EX:

 

#!/bin/bash

nohup java -server -Xmx1g -Xms512m -Xmn342m -XX:MaxPermSize=80m -XX:MaxDirectMemorySize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -Xdebug -Xrunjdwp:transport=dt_socket,address=50242,server=y,suspend=n   
-cp ocs_cdr_per-1.0.0-SNAPSHOT.jar net.snailgame.ocs.per.PerMain applicationContext-per.xml > ocs_cdr_per.log &

 After starting the script, you can use the jps -v command to find this line, -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n , to confirm whether it is started correctly;

Sometimes an error may be reported:

Debugger failed to attach: handshake failed - connection prematurally closed

The reason why I report the error here is that the port 8000 set at the beginning is occupied, which makes it impossible to connect. If you replace the port again, you can connect correctly;

After the service starts, start setting up Eclipse;

Run->Debug Configurations->Remote Java Application->new , fill in Host, Port, and then debug

 

 

For details about Eclipse's remote debugging, please refer to,

Eclipse remote debugging instructions:

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326230032&siteId=291194637