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.

Answer from Abdullah Gürsu on Stack Overflow
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
jetbrains.com › help › idea › run-debug-configuration-spring-boot.html
Spring Boot run configuration | IntelliJ IDEA Documentation
3 weeks ago - For more information, refer to Run a Spring Boot application. In the main menu, go to Run | Edit Configurations…. In the Run/Debug Configurations dialog, click and select Spring Boot.
🌐
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
If you 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 to ...
Top answer
1 of 3
9

Running a Spring Boot project from Maven with a specific profile

mvn spring-boot:run -Dspring-boot.run.profiles=foo,bar

Or by using a shell variable

SPRING_PROFILES_ACTIVE=foo mvn spring-boot:run

Or by passing arguments to the JVM

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=foo,bar"

These are the only methods that I know of that work for Spring Boot v2.0+.
The first option is recognized by the Spring Boot Maven plugin and passes it on to the application JVM.
Since version 2.0 of Spring Boot, the run goal forks the process by default. Since -Dspring.profiles.active is not recognized by the plugin directly, it's only seen by the Maven process and not passed on to the app itself. This is why it doesn't work in the form mvn spring-boot:run -Dspring.profiles.active=foo,bar.
In the second option, the shell variable should be visible to any subprocesses spawned from that shell.

Starting a Spring Boot project in debug mode from Maven

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

Putting it together

mvn spring-boot:run -Dspring-boot.run.profiles=foo,bar -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

Alternative, passing all arguments to JVM

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 -Dspring.profiles.active=foo,bar"

The Maven pom.xml should include the Spring Boot plugin

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.0.1.RELEASE</version>
</plugin>

In IntelliJ you should create a new "Remote" debug configuration from the "Run/Debug Configurations" tool window. You'll find it in the main menu - "Run / Edit Configurations..."
The default config will use the same 5005 port. After that, launch that debug config. The console should display "Connected to the target VM...".

Sources:

  • https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/maven-plugin/examples/run-profiles.html
  • https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/maven-plugin/examples/run-debug.html
2 of 3
3

If you're running from maven, then add the following parameters:

 mvn spring-boot:run -Dspring.profiles.active=dev -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5555"

Here 5555 is a debug port number (you can use any other unoccupied port).

Then in IntelliJ you can use Remote Debug configuration and connect to that port.

If you open the pom.xml from intelliJ, you can create a Run Configuration with --spring.profiles.active=dev and main class that is a class with method main just like in a regular the most simple java application.

🌐
Baeldung
baeldung.com › home › spring › debugging spring applications
Debugging Spring Applications | Baeldung
February 2, 2026 - On the Run/Debug Configurations screen, the Remote JVM Debug template will let us configure how we want to attach to the already running application: Note that IntelliJ only needs to know the hostname and debug port. As a convenience, it tells us the proper JVM command line arguments that should be used on the application that we want to debug. The quickest way to debug a Spring Boot application in Eclipse is to right-click the main method from either the Package Explorer or Outline windows:
🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-142078
Intellij + springboot + maven + spring-loaded + debugging (not ...
December 23, 2022 - {{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
Medium
medium.com › ifelsecoder › spring-boot-maven-plugin-overrides-intellij-idea-debug-parameters-f85ff80090ca
Spring Boot Maven plugin overrides IntelliJ IDEA debug parameters | by Oleksii Kondratiuk | ifelsecoder | Medium
April 26, 2019 - As you can see there is JVM argument specified in the configuration. This is exactly what caused the strange behavior of the plugin. Debug via spring:run in IntelliJ IDEA starts working fine as soon as you remove this configuration.
Find elsewhere
🌐
JetBrains
jetbrains.com › help › idea › spring-debugger.html
Spring debugger | IntelliJ IDEA Documentation
2 weeks ago - Press Ctrl+Alt+S to open settings and then select Plugins. Open the Marketplace tab, find the Spring Debugger plugin, and click Install (restart the IDE if prompted). Spring debugger is supported for the following run configuration types: Spring ...
🌐
Java Development Journal
javadevjournal.com › home › spring › remote debug spring boot application with maven and intellij
Remote debug spring boot application with maven and IntelliJ | Java Development Journal
May 9, 2020 - Next step is to configure IntelliJ to enable debug points, use below steps to configure it · Open run/debug configuration dialogue box and click on the new icon · Create remote configuration , see screen shot below · Click on the debug button ...
🌐
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
🌐
Aries
aries.me › 2020 › 09 › 11 › debug-spring-boot-app-with-intellij-idea-community
Debug spring-boot app with IntelliJ IDEA community – Aries' Blog
September 11, 2020 - In intelliJ IDEA, if you debug a spring boot app by right-clicking the “main” class (e.g. Application.java) and select “Debug”, ClassNotFoundException may happen. As suggested on stackoverflow, we should use maven goal spring-boot:run to debug spring boot app.
🌐
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)
1) why if using spring-boot:run to run, Intellij cannot hit the break point? 2) how to make Intellij can also hit the break point even using spring-boot:run to run? ... IntelliJ works by connecting to the debugger that is built into the JVM. To do that: 1. The (spring-boot) JVM must be started with the debugger enabled 2.
🌐
Javadeveloperzone
javadeveloperzone.com › spring-boot › spring-boot-application-debug-in-intellij
Spring boot application debug in IntelliJ – Java Developer Zone
Table of Contents1. Overview2. Step to debug Spring boot application in IntelliJStep 1: Open or Create ApplicationStep 2: Put Debug PointsStep 3. Start application in debug modeStep 4: Let’s debug code3....
🌐
Vaadin
vaadin.com › docs › latest › tutorial › project-setup
Import, Run & Debug a Maven Spring Boot Project in IntelliJ
December 4, 2023 - This guide will help you set up your environment, create your first Vaadin project, and take you through the essential steps of developing, running, and building your application.
🌐
Baeldung
baeldung.com › home › spring › spring boot › debugging spring boot applications with intellij idea
Debugging Spring Boot Applications With IntelliJ IDEA | Baeldung
1 month ago - The Spring Debugger requires no special configuration — just install the plugin and run the application in the Debug mode. It works with the following run configuration types: ... The plugin integrates with the IDE’s built-in debugger API ...
🌐
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
You could try the suggestion here ...us=Comments-27-4758555.0-0 Or open the main class annotated with `@SpringBootApplication`, and click the run icon in the IDE's left gutter to debug it directly....
🌐
JetBrains
jetbrains.com › help › idea › spring-boot.html
Spring Boot | IntelliJ IDEA Documentation
3 weeks ago - To update a running application, go to Run | Debugging Actions | Update Running Application Ctrl+F10 in the main menu, or select your application in the Services tool window and click .
🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-188058
Jetbrains
July 14, 2022 - {{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong