我可以在 Debug模式下启动架子上的主要 Spring Boot 应用程序我可以在 IntelliJ 中设置断点并且它可以工作! IE。运行如下:
@SpringBootApplication
public class JasperApplication {
public static void main(String[] args) {
SpringApplication.run(JasperApplication.class, args);
}
}
但是,如果我使用带有调试选项的 maven run 插件在 IntelliJ 中启动 Spring Boot 应用程序:
spring-boot:run
调试不起作用。我读过有关
-Drun.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
我无法将所有内容组合在一起,有人可以告诉我这一切是如何运作的,或者指导我阅读一些描述整个内容的文章吗?
我喜欢能够从 IntelliJ 以及命令行中运行 Maven Spring Boot 插件,能够调试和设置断点。谢谢!
最佳答案
当您调用 spring-boot:run
时,您正在启动一个远程进程,即该进程不在您的 IDE 中运行。
如果您想从 IDE 中调试此进程,则需要满足以下先决条件:
远程进程必须是“远程调试感知”,这就是您在使用
-Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y 运行该进程时所做的事情,挂起=y,地址=5005"
您必须在 IDE 中使用远程调试器。更多详情in the docs但简要总结是:
- 运行 > 编辑配置
- 点击
+
图标并选择远程 - 为运行配置命名并为
使用模块的类路径搜索源
选择一个模块 - 调用
mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
并启动此运行配置在您的 IDE 中,两者将相互通信。
这是显示远程运行配置的屏幕截图:
关于java - Maven和SpringBoot调试-Drun.jvmArguments=-Xdebug到底是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47177551/