一、SpringBoot远程调试用例
- 远程调试核心命令
#address 远程调试连接端口
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
- 新建remote-debug-example的maven工程
- pom文件内容如下
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sxx.remote</groupId>
<artifactId>remote-debug-example</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
- 编写测试类
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class RemoteDebugExample {
@GetMapping("/debugExample")
public void debugExample(){
System.out.println("hello debug");
}
}
- 模拟运行远程服务
#1.本地项目打包(remote-dubug-example.jar)
mvn clean package -Dmaven.test.skip=true
#模拟远程运行jar包remote-dubug-example.jar
java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
remote-debug-example.jar --server.port=7083
-
远程控制台出现如下信息
-
配置本地调试客户端
-
启动本地调试
-
浏览器访问远程服务
-
1.断点未跳过时,远程服务状况
- 2.断点跳过后,远程服务状况