Use idea to remotely debug JAVA applications in the production environment

Sometimes it is clear that there is no problem in the test environment, but there are bugs when deployed to the production environment, so I want to directly click the interrupt point of the production environment to go to the local code.
JAVA itself supports the debugging function, and provides a simple debugging tool - JDB, similar to the powerful GDB, JDB is also a character interface debugging environment, and supports setting breakpoints, and supports thread-level debugging.

1. Add to the process startup parameters on the server:

-Xdebug -Xrunjdwp:transport=dt_socket,address=5555,server=y,suspend=n

The meaning of each parameter:
-Xdebug is to notify the JVM to work in DEBUG mode

-Xrunjdwp is to inform the JVM to use (java debug wire protocol) to run the debugging environment. This parameter has a series of debugging options at the same time:
transport specifies the transmission method of debugging data

dt_socket refers to using SOCKET mode

server=y/n Whether the VM needs to be executed as a debug server

suspend=y/n Whether to start the VM after the debug client establishes a connection

Connect to the debugging service provided by myhost:5555, select Remote JVM Debug in Edit Configurations in idea and add the following:
insert image description here

Then start debug and break the point to debug the code.

Guess you like

Origin blog.csdn.net/ABCAA1024/article/details/121677396