【问题标题】:Breakpoints ignored by Intellij running Spring Boot with Gradle使用 Gradle 运行 Spring Boot 时 Intellij 忽略断点
【发布时间】:2016-02-23 22:55:30
【问题描述】:

我正在尝试使用 IntelliJ 14 Ultimate 版本调试 Spring Boot 应用程序。

由于其他问题,该应用程序不会直接在 IDE 中运行(参见底部的屏幕截图),而是使用以下命令通过命令行运行:

./gradlew bootRun -Dspring.profiles.active=dev -Dserver.port=15020 -Dorg.gradle.jvmargs="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5245"

我在 IntelliJ 中的设置:

我将以下内容添加到我的 build.gradle 以使配置文件和端口参数被接受:

bootRun { 
    systemProperties =  System.properties 
}

IntelliJ 中的调试器连接成功,但不会在设置的任何断点处暂停执行。从 IntelliJ 控制台:

Connected to the target VM, address: 'localhost:5245', transport: 'socket'

依赖版本

  • 春季:4.1.3.RELEASE
  • Spring Boot:1.1.8-RELEASE
  • spring-boot-gradle-plugin: 1.1.12.RELEASE
  • Gradle 2.8

在 IDE 中而不是在 CLI 中发生的类路径资源错误:

【问题讨论】:

  • 对您的应用程序的结构一无所知,这很难说,但是您将断点放在什么样的代码中?配置、控制器等?
  • 控制器,我还尝试了一个请求监听器,我知道正在调用日志记录。
  • 听起来 IntelliJ 没有看到与正在运行的应用程序相同的类。您最初是如何在 IntelliJ 中打开项目的?您只是“打开”了 build.gradle 文件还是进行了项目导入?有时它似乎有所作为。
  • 另外,您是否尝试过使用--debug-jvm 运行而不是自己配置? ./gradlew bootRun --debug-jvm(加上您需要的任何其他参数)。我刚刚注意到您正在运行非常旧的版本 - 我假设这从启动开始就可用。
  • 哇,好用 (--debug-jvm)。发布为答案,我会接受。

标签: java spring spring-mvc intellij-idea gradle


【解决方案1】:

使用 Spring Boot 启用调试的首选方法是使用 --debug-jvm 选项:

./gradlew bootRun --debug-jvm

以及您需要的任何其他参数。使用您帖子中指定的方法,我认为您实际上是在调试 Gradle,而不是您的应用程序。

【讨论】:

    猜你喜欢
    • 2016-08-19
    • 1970-01-01
    • 1970-01-01
    • 2014-03-10
    • 2014-08-13
    • 1970-01-01
    • 2015-01-28
    • 2019-03-22
    • 2019-02-05
    相关资源
    最近更新 更多