Turn your wounds into wisdom


It’s obviously almost everyone of us started to use spring-boot few years ago. To kick start a SpringBootApplication, you can either start it from run button in IDE or using following maven command

mvn spring-boot:run

Then you may wonderings what’s the magic to use this command to kick start a Spring Boot application?

Details explained

The Spring Boot Maven plugin includes a run goal which can be used to quickly compile and run your application. Applications run in an exploded form just like in your IDE.

If you navigate to RunMojo.java in project spring-boot-maven-plugin ,you’ll find its the code logic to mvn spring-boot:run. That’s the instruction to Java program.

There are two key methods, (1) runWithForkedJvm (2) runWithMavenJvm

If you keep pom.xml as default, it will actually run runWithForkedJvm,however, if you config pom.xml as below, it will actually kick start runWithMavenJvm

                <jvmArguments>${jvm.args} -Ddns.server= -Dspring.profiles.active=local</jvmArguments>

BTW, if you willing to debug maven plugin, replace mvn with mvnDebug, then check following lines:

[INFO] Attaching agents: [] Listening for transport dt_socket at address: 5050

You can create a remote debug attach to it for troubleshooting.