EDUCBA

EDUCBA

MENUMENU
  • Explore
    • Lifetime Membership
    • All in One Bundles
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Login
Home Software Development Software Development Tutorials Maven Tutorial Maven Central Repository

Maven Central Repository

Payal Udhani
Article byPayal Udhani
Priya Pedamkar
Reviewed byPriya Pedamkar

Updated April 13, 2023

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.

ADVERTISEMENT
Popular Course in this category
MAVEN Course Bundle - 10 Courses in 1 | 6 Mock Tests

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

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>

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>

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

We hope that this EDUCBA information on “Maven Central Repository” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. Maven Plugins
  2. Maven Life Cycle
  3. How to Install Maven
  4. Maven Commands
ADVERTISEMENT
GOLANG Course Bundle - 6 Courses in 1
23+ Hours of HD Videos
6 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
iOS DEVELOPER Course Bundle - 61 Courses in 1
147+ Hours of HD Videos
61 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
JAVA SERVLET Course Bundle - 18 Courses in 1 | 6 Mock Tests
56+ Hours of HD Videos
18 Courses
6 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
RED HAT LINUX Course Bundle - 5 Courses in 1
28+ Hours of HD Videos
5 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • 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

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

EDUCBA

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

Let’s Get Started

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

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA

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

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

Forgot Password?

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

🚀 Extended Cyber Monday Price Drop! All in One Universal Bundle (3700+ Courses) @ 🎁 90% OFF - Ends in ENROLL NOW