Spring boot debug debugging process diagram
This article mainly introduces the spring boot debug debugging process diagram, which is introduced in great detail through the example code, which has a certain reference value for everyone's study or work. Friends in need can refer to it
Recently, it was found that spring boot cannot be debugged locally. After the original spring boot upgrade, the command parameters of the corresponding plug-in have changed, so this paper makes an upgrade.
Background:
When the spring boot project uses the spring boot Maven plug-in to execute the startup command spring boot: run, if the set breakpoint cannot enter, the following settings should be made.
Official solution:
Just look at what to do!
1. Add JVM parameters
Add the jvmarguments configuration to the spring boot Maven plugin.
<project> ... <build> ... <plugins> ... <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.2.0.RELEASE</version> <configuration> <jvmArguments> -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 </jvmArguments> </configuration> ... </plugin> ... </plugins> ... </build> ... </project>
Or specify on the command line:
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,address=5005"
For the latest configuration, please refer to the official instructions:
https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html
2. Add a remote
Add a remote configuration in the development tool:
You only need to determine the host and port parameters.
Host: Address
Localhost: local startup address;
Port: Port
5005: the port specified on the command line above;
3. Start debugging
Start the spring boot project with the jvmarguments parameter first:
Stop the program at the listening port: 5005, and then debug to start remote:
Go back to the project, start the output log, and then you can debug the breakpoint.
This is remote debugging. It can also help you debug remote spring boot applications, but it takes two operations to debug locally, which is a little troublesome.
The above is the whole content of this article. I hope it will help you in your study, and I hope you will support us a lot.