• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1277
  • Last Modified:

maven local, central, remote ropositories


What are differences, similarities, uses of maven local, central, remote ropositories. When, why, how, where we use them.

Please advise.

Any links resources ideas highly appreciated. Thanks in advance
Asked On:
  • 2
1 Solution
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Your "local" repository is just like a cache of all the maven artifacts that have ever been retrieved from remote repositories. It is where maven artifacts are referenced from when building/running applications via maven tools. You have no choice to use/not use this as all maven tools will first check the local repository and then if not present retrieve an artifact from remote repositories.

"central" and "remote" repositories are essentially the same, they are just repositories that are located remote from yourself (and therefore remote/different from your local cache). These are the true source location for the various artifacts. The difference between "central" and just any other "remote" repository, is just that the central repository is the one that is "built-in" to the maven tools, ie. you don't need to explicitly configure this one and so you can still resolve a large number of artifacts with no extra config. Other "remote" repositories are required to store and distribute artifacts that people want to distribute but don't necessarily want in the offical "central" repository, ie. if you build a JAR library and you want to distribute to a few of your friends, you probably wouldn't want that in the main, offical central repository so you just setup your own remote repository.
gudii9Author Commented:
>>are just repositories that are located remote from yourself

How they are located and retrieved from remote location. Using internet. Without internet connection I cannot retrieve or upload from remote/central repository. Please advise
mccarlIT Business Systems Analyst / Software DeveloperCommented:
How they are located and retrieved from remote location. Using internet
Yes, in general you need access to the internet to retrieve, the FIRST time that they are retrieved. As I mentioned above, once they are retrieved form the internet the first time, they are cached into your local repository and from then on, only accessed from that local repository.

Without internet connection I cannot retrieve or upload from remote/central repository
You have a couple of options...

If a machine doesn't have "internet" connection but IS connected via some LAN, WLAN, etc. you can set up a "remote" repository somewhere else on that LAN, on a machine that DOES have internet and it can act as a proxy.

Alternatively, if you have some way of getting the required resources into the machines local repository, than Maven can work just fine from then onwards, without needing the internet connection. This can be done either by giving the machine a temporary internet connection, allowing it to download the required resources, and then removing the internet connection. Or by copying the local repository from another machine that aleady has the required resources cached. The local repository is just a file hierarchy, generally in a directory called something like ".m2" and so you can copy the entire contents (recursively, including subdirectories) to the other machine and it will then be able to access all the same resources locally.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now