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>
At Develop In Java, we've been a part of the Java community for over 10 years. If there's anything you'd like us to cover, just ask !