EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Maven Tutorial Maven Central Repository
Secondary Sidebar
Maven Tutorial
  • Maven Basic and advance
    • What is Maven
    • How to Install Maven
    • Maven Commands
    • Maven GroupId
    • Maven WAR Plugin
    • Maven Build Command
    • Maven Failsafe Plugin
    • Maven Profile
    • IntelliJ Maven
    • Maven Enforcer Plugin
    • Maven Javadoc Plugin
    • Maven WAR Plugin
    • Maven Build Command
    • Maven GroupId
    • Maven Force Update
    • Maven Encrypt Password
    • Maven Environment Variables
    • AssertJ Maven
    • Maven Run Single Test
    • Maven kafka-clients
    • Maven Quickstart Archetype
    • Maven Install Dependencies
    • Maven XMLBeans
    • Maven Local Repository
    • Maven Versions
    • Maven Jar Plugin
    • Maven Assembly Plugin
    • Maven exec plugin
    • Maven Central Repository
    • Maven Surefire
    • Maven Deploy
    • Maven Phases
    • Maven Archetype
    • Maven Skip Test
    • Maven Dependency Scope
    • Maven Shade Plugin
    • Maven Repository Spring
    • Maven Eclipse Plugin
    • Maven Exclude Dependency
    • Maven Life Cycle
    • Maven Repository
    • Maven POM File
    • Maven Plugins
    • What is Maven Plugins
    • Maven Interview Questions
    • Maven Flags
    • Maven Project
    • Maven Settings.XML

Maven Central Repository

By Payal UdhaniPayal Udhani

Maven Central Repository

Introduction to Maven Central Repository

Maven repository is a directory where all the dependencies such as jars, library files, plugins, or other artifacts that will be required by the projects are stored. These repositories help us to store and maintain useful resources so that they can be used in our maven projects while building and deploying the artifacts. All the layout and structure of the underlying repositories of maven of any type are completely hidden for maven users. In this topic, we are going to learn about the MCP.

Type of repositories

There are basically three types of repositories in maven that are local, remote and central repositories.

1. Local Maven Repository

Local repositories are the folders or directory on your machine where maven is used i.e. a local machine that contains the cached jars and dependencies required by your project and other artifacts that are built by you on your machine but not released yet. The operations that the maven user can perform is to clean the local repository if any memory or space-related issue is there on their local repository or completely erase the data on this repository that will further lead to redownloading of the dependencies required by your project. The local repository can be mentioned in your settings.xml file in the following manner –

<settings xmlns = "http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:/sampleLocalRepo</localRepository>
</settings>

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

2. Remote Maven Repository

The remote repositories are the resources that are located remotely and contain directory having jars, library files, and plugins, and other artifacts that might be useful and are accessed by using the protocols such as https:// of file:// protocol. These remote repositories are further segregated into the repositories that are kept at a remote place and shared between multiple individuals and developers for the private use of a company or the third party to maintain and share artifacts. You can mention your remote repositories inside the settings.xml file in the repositories tag and can add multiple repository tags for multiple remote repositories if you wish to configure them in the following way –

<repositories>
<repository>
<id>educba.library</id>
<url>http://educba.org/mavenremoterepo/samplelibrary</url>
</repository>
</repositories>

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,388 ratings)

3. Central Maven Repository

The second remote repository in the maven is the central repository that is available for downloading the dependencies in your maven project and also to release the artifacts that you want to on the central repository. The link for the central maven repository is https://repo.maven.apache.org/maven2/ while the site that is available for searching the maven dependencies available in the central repository of maven is – https://search.maven.org/. This type of remote repository is also called and referred to as the central repository and is available to all and is open source. This repository is provided by the maven community. There is no need for any configurations in settings.xml file for a central repository.

Working of Repository

Whenever the first maven command is fired or the project is built, maven automatically downloads the dependencies such as jars, libraries or plugins required by your project into the local repository and creates one local repository if not present. After that whenever you build your project, maven references to the dependencies that were downloaded and stored in your local repository. This helps in reducing the time required to make the data exchange with the remote repository and saves time as well as cost.

Suppose that while building your project, the maven does not find the dependency on the local repository, it goes for searching it on the central repository. This central repository is provided by the maven community and does not require any configurations to be made in maven but make sure that you have an internet connection available for searching dependencies of your project in the central repository by maven automatically.

Now, even if the repositories are not found in local and central repositories, maven goes for searching them in the remote repositories if mentioned and available. If the remote repository is not available and dependency is not found then an error saying dependency not found is thrown. If the remote repository is available then dependency is searched over there and if not succeded to find it there an error for intimating unavailability of dependency is thrown. In either case, if you succeed to find dependency then it is downloaded to the local repository for further usage and reference.

Maven Central Repository 2

It can be seen that each machine has it’s own local repository and multiple machines in the same network of the organization can share a remote repository while all such different organizations and the machines included in each of organization or any other individual machine having internet connectivity can publicly access the central repository of maven.

Maven Central Repository

The central repository of the maven contains all the collection of jar files, plugins, and libraries that is provided by the maven community to maven users. This repository does not need any configuration to be made just make sure that your IDE/machine is connected to the internet to download and use the dependencies from the central repository.

Many times, it is possible in the organizations that they might not provide internet access due to security and bandwidth reasons. In these cases, we can download a copy of central maven repository resources on the remote repository for offline usage. This needs to mention in your settings.xml file for remote repository paths. It is even possible that you may need other official central repositories distributed across geographies to be used for searching and getting dependencies, this is called as the mirrors in maven and can be used by making certain changes in settings.xml file.

The below diagram displays the components and relationship of other repositories and the user with the central repository of maven. Content Delivery Network(CDN) of the central repository can be seen connected to the maven user via settings.xml file.

Maven Central Repository

Conclusion

There are various types of repositories used in maven for efficient and convenient dependency management. The central repository is one of them and is provided by the maven community that stores all the dependencies such as jars, plugins, and libraries required by any project. This repository can be searched for dependencies using the following link – https://search.maven.org/ and dependencies are present of the link – https://repo.maven.apache.org/maven2/. There is no need for external configurations for setting up a central repository in your maven project just make sure that internet connectivity is available.

Recommended Articles

This is a guide to the Maven Central Repository. Here we discuss the three types of repositories in maven that are local, remote and central repositories. You may also have a look at the following articles to learn more –

  1. Maven Plugins
  2. Maven Life Cycle
  3. How to Install Maven
  4. Maven Commands
Popular Course in this category
Maven Training (4 Courses, 6 Projects)
  4 Online Courses |  6 Hands-on Project |  26+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more