经过测试并与 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>
另外,像这样包含 Spring Devtools 也是一个好主意:
<dependencies>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
...
</dependencies>
现在导航到您的项目设置 -> 操作 -> 调试项目并设置以下内容:
执行目标:
spring-boot:run
设置属性:
run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
jpda.listen=true
现在通过通常的调试按钮运行您的应用程序,Spring 应该正确连接到 JVM 调试器。
Spring Boot 2.x
要为 Spring Boot 2.x 项目(更具体地说是 spring-boot-maven-plugin 的 2.x 版)启用 Netbeans 调试,过程完全相同,除了 run.jvmArguments 属性名称已更改为spring-boot.run.jvmArguments:
spring-boot.run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
jpda.listen=true