Search code examples
spring-bootmavenintellij-idea

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.


Solution

  • 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.