Installing a Jar File Into a Local Maven Repository

# Installing a Jar File Into a Local Maven Repository

##### Posted 5 years ago

Sometimes when a file is not in the Central Maven Repository, it can be necessary to install files into your local Maven Repository. (Note, if you are working in more than a very small team, it’s probably beneficial to install a Nexus repository so that all members of the team get the benefits of any locally deployed artifacts)

To deploy a jar into the local maven repository, issue the mvn install:install-file command as shown below.

mvn install:install-file -DgroupId=your.group.id \
-DartifactId=yourArtifactId \
-Dversion=yourVersionNumber \
-Dpackaging=jar
-Dfile=\path\to\jar\file.jar
-DgeneratePom=true


Once the jar has been added to the local maven repository, it can be added as a dependency within a project’s pom.xml as follows:

<dependency>
<groupId>your.group.id</groupId>
<artifactId>yourArtifactId</artifactId>
<version>yourVersionNumber</version>
</dependency>