Maven cannot download jar packages in a private library

Source: Internet
Author: User

Two days ago a colleague encountered a problem:

The same project, depending on a jar in the private library, the other colleague's project can be successfully downloaded, but only his project will not be able to download the dependency, and finally found the reason, but still here to note:

1. Maven Dependency Management

MAVEN manages project dependencies through Gav coordinates, and if there is a private library inside the company, the order of dependency lookups is this: local warehouses--and private warehouses--and central warehouses (which is not configured for mirror interception) If mirror is configured in setting and Mirrorof is configured to *,url point to the Private library path, the lookup order is the local warehouse--and the private warehouse (the Central warehouse), which is different for the initiator relying on the central warehouse lookup

2. Maven Dependency Path

Dependent paths refer to the inheritance order of the parent of the project structure, in general, the MAVEN module of the project is only divided into 2 levels, namely:

Maven-project-parent (POM)

---maven-project-api (jar)

---maven-project-core (jar)

---maven-project-web (WAR)

There are, of course, multi-level situations:

Maven-project-parent (POM)

---maven-project-loan-parent (POM)

------MAVEN-PROJECT-LOAN-API (JAR)

------Maven-project-loan-core (JAR)

------Maven-project-loan-web (WAR)

---maven-project-invest-parent (POM)

------MAVEN-PROJECT-INVEST-API (JAR)

------Maven-project-invest-core (JAR)

------Maven-project-invest-web (WAR)

3. Maven download Dependency package sequence

The download order is based on a dependent path, such as a MAVEN-PROJECT-INVEST-API project in a multi-level project if it depends on the DEPENDENCY-PROJECT-API project in the following project:

Dependency-project-parent

---dependency-project-api

---dependency-project-core

---dependency-project-web

However, only the API packages in this project are being deploy to the MAVEN private library, so depending on the download order, the project will first go back to download Dependency-project-api's parent pom---dependency-project-parent, But the private library does not, so there will be dependency-project-api.jar in this private library, but cannot download the jar package problem,

4. Solution:

(1) If the source code, the Dependency-project-parent code directly clone to local, and then install to the local warehouse to resolve the dependency

(2) Re-deploy the dependency-project-parent to the private library

This article is from the "General Programmer to CTO" blog, please be sure to keep this source http://1730634.blog.51cto.com/1720634/1746252

Maven cannot download jar packages in a private library

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.