Home > Java > javaTutorial > body text

An article to help you learn spring boot breakpoint debugging

无忌哥哥
Release: 2018-07-23 10:19:46
Original
7638 people have browsed it

I recently imported a Spring Boot project. I don’t understand a lot of the business logic and can’t understand it. I can only debug it to see where to start.

Since it runs directly under the spring boot application, the direct Debug operation cannot enter the breakpoint. It can be seen that there is a problem with my debugging method. After various inquiries, I got the solution. The process is as follows:

1. Configure pom.xml

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
	                <jvmArguments>
	                	-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
	                </jvmArguments>
            	</configuration>
			</plugin>
		</plugins>
	</build>
Copy after login

-Xdebug is to notify the JVM to work in DEBUG mode
-Xrunjdwp is to notify the JVM to use (java debug wire protocol) to run debugging environment. This parameter combines a series of debugging options.
transport specifies the transmission method of debugging data. dt_socket refers to the SOCKET mode.
The server parameter refers to whether it is supported in the VM in server mode.
suspend indicates whether it is in the server mode. After the debug client is established, then execute the VM. If it is y, then the current VM is suspended until a debug client connects and the program execution is not started. If your program is not in server listening mode and is executed quickly, you can choose to block its startup at y.
address=5005 The port number of the debugging server, the port number used by the client to connect to the server.

2. Use maven to build:

Maven startup command: clean install -Ptest -X spring-boot:run (-Ptest means startup in the test environment, remove it during actual application. Otherwise, an error of missing test project will be reported; -X means forced execution). The spring boot project that does not depend on any public configuration can be executed independently (i.e. start button).

build successful!

3. Configure eclipse’s debug tool for debugging

Right-click the project–>select debug as–>Debug Configuration–>Remote Java Application

As shown in the figure below, configure host and port. Since the project is started locally, localhost is used, and port uses the value of the address configured previously, which is port 5005. Then click debug to connect to debug

An article to help you learn spring boot breakpoint debugging

4. Break point, debug

An article to help you learn spring boot breakpoint debugging

The above is the detailed content of An article to help you learn spring boot breakpoint debugging. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template