How to debug Spring Boot with Netbeans via Maven

TwoThe :

After fiddling around for way too long till I got proper debuging setup in Netbeans 8.2 with Spring Boot 1.4.3 I figured I write down my findings as Q&A for others.

The problem is that the default configuration for Netbeans fails to properly launch Spring in debug mode and when you search the internet you only find the outdated information in the Spring docs that won't work.

The solution is simple if you know how. Please find the correct setup instructions below.

TwoThe :

Tested and works with Netbeans 8.2 and Spring-Boot 1.4.3:

First of all make sure you have the Spring Maven plugin included (this should be already included when making a new Netbeans Spring project):

<plugins>
  ...
  <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
      <execution>
        <goals>
          <goal>repackage</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  ...
</plugins>

Also it is a good idea to include the Spring Devtools like this:

<dependencies>
  ...
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
  </dependency>
  ...
</dependencies>

Now navigate to your project settings -> Actions -> Debug project and set the following:

enter image description here

Execute goals:

spring-boot:run

Set properties:

run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
jpda.listen=true

Now run your application via the usual debug button and Spring should properly connect to the JVM debugger.

Spring Boot 2.x

To enable Netbeans debugging for a Spring Boot 2.x project (and more specifically version 2.x of the spring-boot-maven-plugin) the procedure is exactly the same, except the run.jvmArguments property name has changed to spring-boot.run.jvmArguments:

spring-boot.run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
jpda.listen=true

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=452514&siteId=1