Maven custom jar to local repository

Source: Internet
Author: User
Tags sonatype nexus

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.