How to debug Spring Boot application with Eclipse?

My Spring Boot webapp is running just fine, and I'd like to debug it through Eclipse.

So when launching my Remote Java Application debugger, which port should I listen to? And is there a setting on my webapp I have to set to enable debugging?


Solution 1:

Why don't you just right click on the main() method and choose "Debug As... Java Application"?

Solution 2:

There's section 19.2 in Spring Boot Reference that tells you about starting your application with remote debugging support enabled.

$ java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n \
   -jar target/myproject-0.0.1-SNAPSHOT.jar

After you start your application just add that Remote Java Application configuration in Run/Debug configurations, select the port/address you defined when starting your app, and then you are free to debug.

Solution 3:

Easier solution:

Instead of typing mvn spring-boot:run, simply type mvnDebug spring-boot:run

You will still need to attach the debugger in Eclipse by making a new Debug Configuration for a "Remote Java Application" on the relevant port.