'Unable to debug a Spring Boot App. The breakpoints always escape

Here's my Spring Boot config

@SpringBootApplication
public class ServicesApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServicesApplication.class, args);
    }
}

Running it using

java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar services-0.0.1-SNAPSHOT.jar

Connecting to the Debug port 8000 from Eclipse Standard (Socket Attach) localhost and port 8000.

Here's what I see in Eclipse

Eclipse Debug screen

But my breakpoints are not hit. I carefully put breakpoints in the Controller, tried putting them in various places in the Service layer, DAO etc. But the Breakpoints aren't getting hit.

I even tried the Right click -> Debug option in Intellij (Right click on the Spring boot run under Maven Projects view.) The app starts in debug mode and the IDE attaches to it but the breakpoints aren't being hit.

What could be causing this?



Solution 1:[1]

Not sure why my steps laid out in the question do not work but I instead chose to debug this is a vanilla Java app with a main method (Since Spring boot apps have a main method to bootstrap). Could've been a bug in the IDE or the specific version of Spring boot.

Solution 2:[2]

I understand that I am joining party late. But for me it started after correcting the basepackage on @ComponentScan(basePackages = { "com.package.app.web"}) and it worked for me.

Solution 3:[3]

This is covered in better detail here - https://stackoverflow.com/a/47064387/13737427

TL;DR because spring-boot:run forks, the debugger is not attached to the right process.

use the follow maven goal to not fork:

spring-boot:run -Dspring-boot.run.fork=false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Ashish
Solution 3 ThisCompSciGuy