Choosing How to Run a Spring Boot Application in IntelliJ IDEA
Decide how to run a Spring Boot app in IntelliJ IDEA: compare IDE launch, Maven/Gradle plugins, and jar execution with trade‑offs and validation steps.
01 Sept 2026, 14:18 UTC

Decision and Constraints
When developing a Spring Boot application in IntelliJ IDEA you can start the program in three ways:
- IntelliJ’s built‑in Spring Boot Run Configuration (Ultimate Edition)
- Maven plugin
spring-boot:runor Gradle taskbootRun - Executing the packaged
.jarwithjava -jar
Constraints to consider:
- Availability of live reload and debugging
- Need for command‑line reproducibility in CI
- Desire to run the exact artifact that will be deployed
- Edition of IntelliJ (Ultimate vs Community)
Comparison Table
| Option | Startup Speed | Live Reload / Hot‑Swap | Debugging Integration | CI‑Friendly | Production Parity |
|---|---|---|---|---|---|
| IntelliJ Run Configuration | Fast (IDE process) | Yes (IDE hot‑swap agent) | Full (breakpoints, step‑through) | No (requires IDE) | Medium (uses IDE classpath) |
Maven spring-boot:run | Moderate (Maven lifecycle) | Limited (depends on forked JVM) | Possible via remote debug | Yes | High (uses same plugins) |
Gradle bootRun | Moderate | Limited | Possible via remote debug | Yes | High |
Packaged .jar | Slowest (full start) | No (requires restart) | Possible via remote debug | Yes | Highest (exact artifact) |
Trade‑offs
If you need instant feedback while editing code, the IDE configuration gives the quickest loop and lets you set breakpoints without leaving the editor. This works only in IntelliJ Ultimate; Community Edition users must fall back to the main class or external tools.
When you want a repeatable command that can be run on a build server, the Maven or Gradle plugins are preferable. They honor the same resource filtering and profile activation as the IDE, but attaching a debugger requires launching the JVM with -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 and then connecting remotely.
Running the .jar mimics the production environment most closely. It is useful for final validation, but any code change forces a rebuild and restart, which slows iterative development.
Concrete Implementation and Validation
Create a minimal controller to verify that the chosen launch method executes your code.
@RestController public class HelloController { @GetMapping("/hello") public String hello() { return "Hello from Spring Boot"; } } Place the file under src/main/java/com/example/demo/HelloController.java (adjust the package to match your project).
Using the IntelliJ Run Configuration
- Open the
Runmenu and selectEdit Configurations…. - Click the
+button, chooseSpring Boot, and ensure theMain classpoints to your application’s@SpringBootApplicationclass. - Select
Debug'instead ofRunto start the process with the IDE’s hot‑swap agent. - Once the application is listening on
http://localhost:8080, open a browser or runcurl http://localhost:8080/hello. - In the IDE’s debugger view you should see the thread suspended at the breakpoint you set inside the
hello()method. After resuming, the request returns the expected string.
Using Maven
- From a terminal in the project root run:
- Attach a remote debugger from IntelliJ (
Run → Attach to ProcessorRun → Debug…with aRemoteconfiguration pointing to localhost:5005). - Set a breakpoint in
HelloController#hello()and repeat the curl request; the debugger should halt.
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" Using Gradle
- Execute:
- Follow the same remote‑debug steps as for Maven.
./gradlew bootRun --jvm-args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" Running the Packaged Jar
- Build the artifact:
- Start it with debugging enabled:
- Attach the remote debugger and verify the breakpoint as described above.
mvn clean package # or ./gradlew clean build java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar target/demo-0.0.1-SNAPSHOT.jar If the breakpoint is hit and the response is returned after resuming, you have confirmed that the launch method correctly executes your code.
Limitations and Practical Checks
- The IDE configuration does not work in IntelliJ Community Edition; you must use the main class or external plugins.
- If your project uses AspectJ or other bytecode‑enhancing agents, the IDE’s hot‑swap agent may be disabled, falling back to a restart‑based reload.
- Always verify that the IDE’s project view reflects the latest Maven/Gradle dependencies (
Maven → ReimportorGradle → Refresh) to avoidClassNotFoundExceptionat startup. - To check that live reload is active, edit a string in a controller, save the file, and refresh the browser; the change should appear without a full restart when using the IDE configuration.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.