The main difference between the “mvn package” and “mvn install” commands is that mvn package command will compile the source and will package it in its distributable formats, such as a JAR or WAR. The mvn install command, however, additionally to compiling the source code and packaging it into a JAR or a WAR, it will also install the package into the local repository, for use as a dependency in other projects locally.
For video lessons on how to secure your Spring Boot application with OAuth 2.0. and Spring Security 5, please checkout my complete video course OAuth 2.0. in Spring Boot applications.
Below is what these two commands do according to maven documentation:
- mvn package – take the compiled code and package it in its distributable format, such as a JAR,
- mvn install – install the package into the local repository, for use as a dependency in other projects locally.
Both of these maven commands will compile your code, clean the /target folder, and will place a new packaged JAR or WAR into that /target folder. It is just the “mvn install” command will also install the package into the local maven repository, for use as a dependency in other projects locally.
I hope this short comparison is helpful.
Happy learning Maven 🙂!