Useful maven command for developers

What is maven?

Maven is a “build management tool” for developers. Maven defines how .java files get compiled to .class, packaged into .jar (or .war or .ear) files, manages the CLASSPATH and other tasks that are required to build the project.

Maven is similar to Apache Ant or Gradle or Makefiles in C/C++. It is completely self-contained that we do not need any additional tools or scripts for downloading & installing necessary libraries.

Following are some useful maven command for developers to use.

Run spring boot but skip the test cases:

$ mvn spring-boot:run -Dmaven.test.skip=true

Clean a project:

// If we rename a class, the previous compiled version will remain in target/classes until we run clean
$ mvn clean

Compile a project:

// Compile the source code clean
$ mvn compile