Apache maven provides a great solution for project building, which caches resources from remote agent warehouses or central warehouses in a local repository, thus improving the efficiency of network resource use, and is very powerful!
However, not all resources can be obtained from the central or agent repository based on GroupID, Artifactid, and version information. For example, the driver for an Oracle database, which is not available for public network Maven repositories provided by any organization for copyright reasons, is unlikely to provide the jar package resources. At this point, if our project is built using MAVEN, you can choose to install the Oracle Driver jar package as a MAVEN artifact to the local repository for development use.
Of course, it's a good idea to use the Sonatype nexus to build a maven, but that's another topic.
It is not possible to manually create a folder and copy the jar package file directly under the local warehouse path, because it is too cumbersome to manually write the Pom.xml file yourself. This article will give you the simplest way to install a jar package into the local repository via the command line.
With the Oracle 12c driver example, the driver is stored under the Oracle_home\product\12.1.0\dbhome_1\jdbc\lib path, it is recommended to use the Ojdbc7.jar file, which requires JDK version above 1.7. The file can be copied out to the D-Packing directory to streamline the subsequent specified path.
Make sure that the MVN command (which can be verified by mvn-v) is used correctly in cmd, and then use the following command:
MVN Install:install-file-dfile=d:\ojdbc7.jar-dgroupid=com.tech4j.driver-dartifactid=oracle-connector-java- Dversion=12.1-dpackaging=jar
In this command, the-dfile parameter specifies the path where the jar package file is located and, in turn, specifies the custom GroupID, Artifactid, and version information.
In this way, you can easily and quickly install third-party jar packages to the local repository for use by MAVEN projects. For example:
<Dependency> <groupId>Com.tech4j.driver</groupId> <Artifactid>Oracle-connector-java</Artifactid> <version>12.1</version> </Dependency>
Maven custom jar to local repository