How to add jar file in your Maven local repository using command line?
Due to binary license related issues few jar files will not be part of Maven public repositories. You can
add them as part of your local maven repositories. Here is an example with Oracle JDBC driver:
This example gives step by step introductions to add Oracle JDBC driver into your Maven local repository
and also how to reference it into your pom.xml file.
First download ojdbc jar file from Oracle JDBC Driver Website
Then run below maven command: (change values according to downloaded file name & version)
mvn install:install-file -Dfile=<your-jar-file-location> -DgroupId=com.oracle
-DartifactId=ojdbc6 -Dversion=<your-jar version> -Dpackaging=jar
|
Now add a dependency in your pom.xml as shown below, which references the jar from your local maven repository.
<!-- ojdbc7.jar example -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>
|
This example is valid not only for Oracle driver, it is valid for any jar file which is not available in
maven public repository. All you need to do is change values for -Dfile, -DgroupId, -DartifactId and -Dversion.
|