Maven dependency mechanism

Source: Internet
Author: User
Tags maven central

1.Maven Local Resource Library

2.Maven Central Repository

3.Maven Remote Storage

The Dependency library query order for MAVEN changes to:

    1. Search in Maven local repository, if not found, enter 2nd step, otherwise exit.
    2. In the Maven central repository search, if not found, enter the 3rd step, otherwise exit.
    3. (need to be declared in Pom.xml) in Maven remote repository search, if not found, prompt for error message, otherwise exit.
    4. The actions are based on the Pom.xml configuration file.

①: Adding a Jar package dependency

Declaring Log4j's MAVEN coordinates into a pom.xml file, the jar package will be searched in the same manner as described above.

When Maven compiles or builds, the log4j jar is automatically downloaded and placed into the MAVEN local repository.

<dependencies>    <dependency><groupid>log4j</groupid><artifactid>log4j</ Artifactid><version>1.2.14</version>    </dependency></dependencies>

②: Add java.net remote Repository.

Role: Used to search for dependent jar packages, and the jar package does not exist in the local warehouse and the central repository.

<project ...> <repositories>    <repository>      <id>java.net</id>      <url >https://maven.java.net/content/repositories/public/</url>   </repository> </ Repositories> </project>  

③: Add JBoss remote Repository.

Role: Used to search for dependent jar packages, and the jar package does not exist in the local warehouse and the central repository.

<project ...>    <repositories>      <repository><id>jboss repository</id><url >http://repository.jboss.org/nexus/content/groups/public/</url>      </repository>    </ Repositories></project>

Maven dependency mechanism

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.