Spring Boot maven插件debug

想在IDEA中用maven的spring-boot插件方式debug Spring Boot应用。

Spring Boot项目的pom.xml文件中有

<plugins>
    <plugin>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-maven-pluginartifactId>
    plugin>
plugins>

在IDEA的右上角新建一个Maven Configuration
Spring Boot maven插件debug_第1张图片

Command line: spring-boot:run -Ddev=true “-Dspring-boot.run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005”

然后新建一个Remote Configuration

Spring Boot maven插件debug_第2张图片
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

然后debug方式启动maven配置,控制台会输出如下内容:

[INFO] >>> spring-boot-maven-plugin:2.1.6.RELEASE:run (default-cli) > test-compile @ content-admin >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ content-admin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 26 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ content-admin ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ content-admin ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ content-admin ---
[INFO] Not compiling test sources
[INFO] 
[INFO] <<< spring-boot-maven-plugin:2.1.6.RELEASE:run (default-cli) < test-compile @ content-admin <<<
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.1.6.RELEASE:run (default-cli) @ content-admin ---
[INFO] Attaching agents: []
Listening for transport dt_socket at address: 5005

可见,它在监听5005端口

然后运行remote配置,即可进入断点。

参考资料:
1.https://blog.csdn.net/feicongcong/article/details/80510183
2.https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html
3.https://www.cnblogs.com/soul-wonder/p/8968460.html

你可能感兴趣的:(java,spring,IDEA)