is it required to mvn clean install before mvn spring-boot:run

Viewed 7595

Pulled an existing project form Git Repo

I tried running it using mvn spring-boot:run , but it gave error

Then performed a mvn clean install then did mvn spring-boot:run, and it got running !!!

Earlier I was supposing mvn spring-boot:run performs the task of mvn clean install also !

But then, How does mvn spring-boot:run considers latest code at compilation (I mean if it is not doing install it should not be compiling, so it should be running the stale JAR, but it takes the new code changes and refreshes the JAR)

Can somebody through some light on the confusion !

2 Answers

mvn clean install is used to resolve dependencies that are listed on your pom.xml. You don't need to run it if there are no changes to your pom.xml. The error was most likely due to your local not having all the dependencies required.

The only difference between mvn spring-boot:run and mvn clean install is the later phases after testCompile phase. Please refer to attached screenshots.

mvn spring-boot:run

enter image description here

mvn clean install

enter image description here

The later steps after running tests in mvn clean install are -

Building jar, repackage, install (default-install)

However as compilation is done, so any changes in source code must be reflected in either case.

Related