如何通过Maven使用Netbeans调试Spring Boot

Two*_*The 11 java spring netbeans maven

经过长时间的摆弄,直到我在Netbeans 8.2中使用Spring Boot 1.4.3进行了适当的调试设置,我想我将其调查结果记录为其他人的Q&A.

问题是Netbeans的默认配置无法在调试模式下正确启动Spring,当您搜索Internet时,您只能在Spring文档中找到不起作用的过时信息.

如果您知道如何解决方案很简单.请在下面找到正确的设置说明.

Two*_*The 17

测试并使用Netbeans 8.2和Spring-Boot 1.4.3:

首先确保包含Spring Maven插件(在制作新的Netbeans Spring项目时应该已经包含这个插件):

<plugins>
  ...
  <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
      <execution>
        <goals>
          <goal>repackage</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  ...
</plugins>
Run Code Online (Sandbox Code Playgroud)

同样包含这样的Spring Devtools是个好主意:

<dependencies>
  ...
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
  </dependency>
  ...
</dependencies>
Run Code Online (Sandbox Code Playgroud)

现在导航到您的项目设置 - >操作 - >调试项目并设置以下内容:

在此输入图像描述

执行目标:

spring-boot:run
Run Code Online (Sandbox Code Playgroud)

设置属性:

run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
jpda.listen=true
Run Code Online (Sandbox Code Playgroud)

现在通过常用的调试按钮运行您的应用程序,Spring应该正确连接到JVM调试器.

  • 它对我不起作用...当我在调试模式下运行时,调试输出打印"JPDA Listening Start ..."并没什么好事......你知道什么是happing? (2认同)