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.

Answer from lrkwz on Stack Overflow
๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 6796164198546-Intellij-not-stopping-at-breakpoints
Intellij not stopping at breakpoints โ€“ IDEs Support (IntelliJ Platform) | JetBrains
If you really need to use Maven goal for debugging you need to add debug arguments to the process which runs the boot run maven goal, see https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/maven-plugin/examples/run-debug.html And then connect ...
๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 12637593520402-Breakpoints-not-working-in-spring-boot-app
Breakpoints not working in spring boot app โ€“ IDEs Support (IntelliJ Platform) | JetBrains
I downloaded latest Community Edition intellij idea IDEA 2 month ago. When I debug sprint boot project, program does not stop on breakpoints, it continues to run as if no breakpoints were set. What...
Discussions

spring boot - Cannot debug / stop a springboot app with IntelliJ Idea community - Stack Overflow
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 More on stackoverflow.com
๐ŸŒ stackoverflow.com
java - How to debug spring-boot application with IntelliJ IDEA community Edition? - Stack Overflow
I'm having difficulties in debugging a Java spring-boot application on IntelliJ IDEA community Edition. The main problem is, that the IDE won't stop on a breakpoint, even the program surely executes More on stackoverflow.com
๐ŸŒ stackoverflow.com
IntelliJ debugger no longer stops at breakpoints
Just a stab in the dark, but did you re-select and run your remote debug run configuration? IntelliJ retains the last run config, regardless of how it was executed. If not, you need to provide a lot more detail. That SO post is likely to get removed for lack of detail and being possibly off-topic (IDE-specific). More on reddit.com
๐ŸŒ r/IntelliJIDEA
5
6
February 8, 2023
java - Spring Boot application doesn't stop at any breakpoint in debug - Stack Overflow
What I should do to make my IDEA stop at breakpoint in debug? I suppose that issue is about forking JVM but can't resolve it. ... No, because it's not Maven application in that tutorial. ... Looks like IntelliJ is not connected to the running application. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Top answer
1 of 13
213

EDIT: it does not work anymore from Spring Boot 3+. See Ruik's comment


tldr: You can try tweaking the command line like this:

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

Explanation:

When running the application in debug mode, the IntelliJ debugger attaches to the Java process that it starts itself (by appending the appropriate parameters, -agentlib:jdwp etc, to the Java command line).

Quite often, these Java processes might then fork a new instance, which is not getting the same parameters, and because it is in a separate process, is not connected to the debugger. This can be confusing.

The spring-boot:run Maven goal, in addition to forking a new JVM, creates even more confusion, because it sometimes does fork and sometimes doesn't, depending on the options it gets, among other things. Some of this can be found in the documentation, but it's not always obvious.

You should first check whether the Java process actually is being debugged at all. When you start the application from IntelliJ, you will see messages scrolling by in the Run / Debug tab. At the top, there's the command line that is being executed. It should contain the debugger parameters (-agentlib:jdwp etc) and it should be followed by a message saying "Connected to the target VM", which is the debugger confirming that it has contact.

Next, if you are unsure if the JVM has been forked, you can check the process list in your OS, for example under MacOS and *nix you can use ps aux | grep java. The Java processes typically have a giant parameter list, most of which is the class path. The actual application being run is at the very end of the command line. If the JVM was forked, you have the process running the Maven goal, and another one running the Spring application. Then your debugger will be connected to the process you are not interested in, and your breakpoints won't work.

To stop spring-boot:run from forking, you can use the fork parameter above.

2 of 13
109

The only approach that worked for me, is running or debugging application directly from Intellij Idea. Just open class which contains

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

And click right mouse button->Debug my application

๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 360009993679-Spring-boot-app-doesn-t-stop-on-breakpoints-and-doesn-t-kill-process-after-stopping
Spring boot app - doesn't stop on breakpoints and doesn't kill process after stopping โ€“ IDEs Support (IntelliJ Platform) | JetBrains
So today, my spring boot app doesn't stop on breakpoints, and when I need to re-run it with gradle's bootRun task, previously running instance is not stopped automatically - and because they use some shared recourse, I have to kill it manually. ... Hello. Does it help if you remove .idea folder and reimport the project? ... Hi In fact, yes and no. I checked out repo from scratch, changed run/build "with intellij" instead of "with gradle" and also in debug configuration -> added "debug all tasks" in "gradle debug" tab.
Find elsewhere
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 769783 โ€บ intellij-idea โ€บ ide โ€บ spring-boot-run-hit-break
spring-boot:run cannot hit break point (IntelliJ IDEA forum at Coderanch)
in run configuration, I choose Maven and set run command as spring-boot:run, then I set break point in code and run the configuration, but I find intellij cannot hit the break point. but if I create another run configuration, choose Application and set the main class, then when run this configuration, Intellij can hit the break point.
๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 10000635378450-IntelliJ-debugger-no-longer-stops-at-breakpoints
IntelliJ debugger no longer stops at breakpoints โ€“ IDEs Support (IntelliJ Platform) | JetBrains
February 8, 2023 - Use TcpView to ensure it's a correct Tomcat instance listening for debugger on port 8000. Make a change in your code like adding a logging statement, put a breakpoint on this line, build/deploy the new app, restart Tomcat.
๐ŸŒ
DEV Community
dev.to โ€บ davey โ€บ debugging-springboot-application-in-intellij-idea-ce-22j9
Debugging SpringBoot Application In IntelliJ Idea CE - DEV Community
October 12, 2022 - When debugging a SpringBoot application in IntelliJ Idea Community Edition, additional steps need to be taken. If you have defined your run configuration as spring-boot:run, you will find that the application runs, but does not stop at breakpoints as expected.
๐ŸŒ
Reddit
reddit.com โ€บ r/intellijidea โ€บ intellij debugger no longer stops at breakpoints
r/IntelliJIDEA on Reddit: IntelliJ debugger no longer stops at breakpoints
February 8, 2023 -

Using IntelliJ Community Edition 2022.3.2 for Windows, I was debugging just fine until I decided to run some unit tests manually by going to the file in the proyect explorer, double clicking it and selecting "run". As a result, the debugger (Remote JVM Debug) no longer stops at breakpoints.

My best guess is that running the unit test created another JVM or Java Project and the debugger attachs to it whenever I run it but I tried restarting my PC to kill all processes and didยดt work. Also tried uninstalling Tomcat and IntelliJ because I notice that before running the unit test, it built the proyect and thatยดs something I never do using the IntelliJ Build Project tool, I always do it via CMD

I created a post in StackOverflow but got no answer. Pelase feel free to check the post asi i added a lot more information there.

Any kind of information or workaround I can try is welcome, i have been struggling with this issue for 2 days now.

๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 360001580439-Not-able-to-hit-a-breakpoint-in-IntelliJ-when-trying-to-remote-debug-a-executing-test
Not able to hit a breakpoint in IntelliJ when trying to remote debug a executing test โ€“ IDEs Support (IntelliJ Platform) | JetBrains
November 16, 2018 - I have a spring boot project (Java 8, JUnit 4). I am using IntelliJ (Ultimate 2018.2) for IDE. My test passes when I run from within IntelliJ but fails when I run it from command line using gradle test command. So I am trying to remote debug my Junit test. I have breakpoints set. But when the test is executing the debugger is not stopping ...
๐ŸŒ
tutorialpedia
tutorialpedia.org โ€บ blog โ€บ how-to-debug-spring-boot-application-with-intellij-idea-community-edition
Debugging Spring Boot in IntelliJ IDEA Community Edition: How to Fix Breakpoints Not Stopping (Maven Configuration) โ€” tutorialpedia.org
... Check for Port Conflicts: Ensure port 5005 (or your custom port) isnโ€™t blocked by a firewall or used by another process. Run netstat -tulpn | grep 5005 (Linux/macOS) or netstat -ano | findstr :5005 (Windows) to check.
๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 9250565005586-Maven-Run-configuration-spring-boot-unable-to-debug
Maven Run configuration spring boot unable to debug. โ€“ IDEs Support (IntelliJ Platform) | JetBrains
Running the app works just fine, but if I try to start it in debug mode, it never hits any of my breakpoints. The same app running with a Spring Boot run configuration starts in debug mode just fine. However, Spring Boot run does not generate a build.properties file like mvn spring-boot:run does which my app needs to be able to run correctly. I found this: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360007199739/comments/360002405220 Is there any way to get spring run config to both generate the BuildProperties bean that my app needs while also using the SpringBoot run configuration?
๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 360000417780-Test-Class-Breakpoint-does-not-stop
Test Class Breakpoint does not stop โ€“ IDEs Support (IntelliJ Platform) | JetBrains
Do you build by IDE or external build tool (Maven/Gradle)? Try Build | Rebuild action. Also make sure the code where you set a breakpoint is actually executing. ... I have pretty much the same problem on my end here!
๐ŸŒ
JetBrains
youtrack.jetbrains.com โ€บ issue โ€บ IDEA-188058 โ€บ cant-debug-spring-boot-project-by-spring-bootrun
can't debug spring boot project by "spring-boot:run"
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 360007199739-unable-to-debug-spring-boot-application-with-postman-requests
unable to debug spring boot application with postman requests โ€“ IDEs Support (IntelliJ Platform) | JetBrains
Postman send the request and the app is processing successully (see the logs) and see the response back in postman but IDEA doesn't stop in the breakpoint. breakpoint is not disabled. ... If you are using Maven configuration, IDE debugger connects to the Maven JVM and breakpoints will not work as your code runs in the different JVM forked by Maven. Consider using IntelliJ IDEA Ultimate with the Spring Boot debug configuration or use Application debug configuration instead of Maven.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 63814541 โ€บ spring-boot-application-doesnt-stop-at-any-breakpoint-in-debug
java - Spring Boot application doesn't stop at any breakpoint in debug - Stack Overflow
I run the application in debug with mvnDebug in Windows with IntelliJ IDEA 2020: ... MAVEN_DEBUG_OPTS in ${MAVEN_HOME}\bin\mvnDebug.cmd: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 -DforkMode=never -Dmaven.failsafe.debug ยท So I started the app, see a prompt: Listening for transport dt_socket at address: 5005 ยท Then I ran 'remote' run configuration. I can see how my app has started. Then I invoked controller's endpoint. I can see stop string in the log. Then I put a breakpoint at string System.out.println("stop");. Invoked again controller's method.