The spring-boot:run goal of the Spring Boot Maven Plugin compiles your project and starts the application straight from Maven, using the project's classes and resolved dependencies on the classpath. You do not have to package a JAR first, which makes it the quickest way to start a Spring Boot app during development with mvn spring-boot:run.
It launches your main method in a forked JVM, so the embedded server (Tomcat by default) starts exactly as it would from an IDE or java -jar. The goal is meant for development and testing, not for production deployment.
The goal belongs to spring-boot-maven-plugin. When you invoke it, Maven first runs the lifecycle up to the compile and resources phases, so your sources and application.properties or application.yml files are built into target/classes. The plugin then locates the class that has a main method, builds a classpath from target/classes plus all runtime dependencies, and starts the application in a separate JVM process.
Because nothing is repackaged, the start-up is fast and you always run what is currently on disk. Press Ctrl+C to stop the application and the forked JVM.
Projects generated by Spring Initializr already contain the plugin. If you use your own parent POM, add it to the build section. When the project inherits from spring-boot-starter-parent, the version is managed for you.
If you do not use the starter parent, import the spring-boot-dependencies BOM or set the plugin version explicitly, otherwise Maven cannot resolve the plugin version.
Start the application from the project directory:
You should see the Spring banner and a line similar to this:
The default port is 8080, so a web application is reachable at http://localhost:8080.
Because the application runs in a forked JVM, Maven options do not automatically become application settings. The plugin has dedicated properties for this, and they are the reliable way to configure a run.
| Goal | Property | Example |
|---|---|---|
| Activate profiles | spring-boot.run.profiles | -Dspring-boot.run.profiles=dev |
| Application arguments | spring-boot.run.arguments | -Dspring-boot.run.arguments="--server.port=8081" |
| JVM options | spring-boot.run.jvmArguments | -Dspring-boot.run.jvmArguments="-Xmx512m" |
| Environment-style properties | spring-boot.run.systemPropertyVariables | configured in the POM |
| Main class | spring-boot.run.mainClass | -Dspring-boot.run.mainClass=com.example.App |
Examples:
You will often see -Dspring.profiles.active=dev or -Dserver.port=8081 in older tutorials. Whether a plain -D flag reaches the forked application depends on the plugin version and setup, so prefer the spring-boot.run.* properties above. Environment variables such as SPRING_PROFILES_ACTIVE=dev also work, because the forked JVM inherits the environment of the Maven process.
If spring-boot-devtools is on the classpath, the application restarts automatically when classes change. Combine this with an IDE or a second terminal running mvn compile to get fast feedback. Add the dependency with optional scope so it is never part of a packaged artifact:
DevTools disables itself when the application is started from a fully packaged JAR, which is why the setting is safe for production builds.
| Approach | Needs a build first | Typical use |
|---|---|---|
mvn spring-boot:run | No, compiles only | Local development, quick manual tests |
java -jar target/app.jar | Yes, mvn package | Running the real artifact, production |
| IDE run configuration | No | Debugging, hot reload |
mvn spring-boot:start and spring-boot:stop | No | Starting the app around integration tests |
./gradlew bootRun | No | Gradle equivalent of spring-boot:run |
Two related goals are worth knowing. spring-boot:test-run starts the application with test-scoped classes on the classpath, which is useful with Testcontainers-based TestApplication classes. spring-boot:start and spring-boot:stop launch the app in the background and shut it down, so integration tests can run in between.
spring-boot: the plugin is missing from the POM and the parent does not manage it. Add spring-boot-maven-plugin as shown above.main method. Set <mainClass> in the plugin configuration or pass -Dspring-boot.run.mainClass.--server.port=8081 through spring-boot.run.arguments.No. It only compiles the code and starts the application from target/classes and the dependency JARs. Use mvn package to produce the executable JAR.
It is not intended for that. Production should run the packaged JAR or a container image, which is faster to start, reproducible and independent of Maven.
Use mvn spring-boot:run -Dspring-boot.run.profiles=dev. Spring then loads application-dev.properties or application-dev.yml on top of the default configuration.
Run ./gradlew bootRun. Arguments are passed with --args='--spring.profiles.active=dev'.
The spring-boot:run goal compiles your project and runs the application directly from Maven, which gives you a short development loop without packaging. Configure profiles, arguments and JVM options through the spring-boot.run.* properties, add DevTools for automatic restarts, and use mvn package with java -jar when you need the real deployable artifact.