Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot debug / stop a springboot app with IntelliJ Idea community

My Idea setup cannot stop on breakpoints and not even stop the launched/debugged process.

Environment:

  • ubuntu 20.04.1 LTS
  • openjdk version "1.8.0_275" 64 bit
  • IntelliJ Idea 2020.2

Steps to reproduce:

  • Create a maven "demo" application from https://start.spring.io/ (Spring Web dependency will suffice)
  • Download IntelliJ Idea and launch idea.sh
  • Open pom.xml file to import the project in the IDE
  • Add a @RestController returning "Hello world" for @GetMapping("/")
  • Drop a couple of breakpoints in the App and in the newly created controller
  • Configure a maven launcher with spring-boot:run command line
  • Hit the debug button

The application launches and you can call http://localhost to see the "Hello world"; you can even change the code and the app nicely reloads but ... it does not stop on breakpoints.

When you hit the stop button the IDE detaches from the process but does not stop it.

What's wrong with my setup?

BTW: debugging works smoothly for a simple cli maven java application.

like image 753
lrkwz Avatar asked Oct 20 '25 17:10

lrkwz


1 Answers

Thanks to the suggestion from https://stackoverflow.com/a/47064387/509565 I've worked out the solution:

  1. Use spring-boot:run -Dspring-boot.run.fork=false as your laucher command line
  2. Ensure that "Delegate IDE build/run actions to Maven" in "Build ...> Build Tools > Maven > Runner" settings is NOT checked

Edit:

It seems that this trick isn't working anymore (Intellij-Idea 2024.4.4, Java 17): you can always start the application from the @SpringBootApplication itself.

like image 50
lrkwz Avatar answered Oct 23 '25 07:10

lrkwz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!