Remote debugging in spring boot projects doesn't work with Java jdk 9.0.1 (tested with multiple spring boot projects in Java jdk 9.0.1, none of them works).
Gets error "Failed to attach to remote debuggee VM. Reason: java.net.ConnectException: Connection refused: connect" when try to remote debug. Spring boot doesn't stop to wait for the debugger to attach.
Run command:
$ mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
What's your spring-boot version? Refers to spring-boot wiki: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-Java-9, spring-boot 1.5.x doesn't support java 9.
Sorry I didn't mention my spring boot version. It's 2.0.0.M7 . Version 2.x should support Java 9.
The error message "java.net.ConnectException: connection refused" generally means the debug port 5005 is not really opened at your program. Could you share the console message for the cmd mvn spring-boot:run? Besides, can you remote debug it with other IDEs such as eclipse/intellij?
I have found out that to run remote debugging with the new version of spring boot (2.x.x, supports Java JDK 9), command line argument needs to be changed from -Drun.jvmArguments to -Dspring-boot.run.jvmArguments. The new spring-boot:run command for remote debugging should be:
$ mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
For future reference, check the command line argument for adding JVM arguments to spring-boot:run here:
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java#L105
Excerpt:
@Parameter(property = "spring-boot.run.jvmArguments")
private String jvmArguments;
Most helpful comment
I have found out that to run remote debugging with the new version of spring boot (2.x.x, supports Java JDK 9), command line argument needs to be changed from
-Drun.jvmArgumentsto-Dspring-boot.run.jvmArguments. The new spring-boot:run command for remote debugging should be:For future reference, check the command line argument for adding JVM arguments to spring-boot:run here:
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java#L105
Excerpt: