A Maven repository is a storage location for build artifacts, such as JARs, POMs and plugins, that Maven downloads dependencies from and publishes your own artifacts to. There are three kinds: the local repository on your machine (~/.m2/repository), remote repositories such as Maven Central or a company server, and the mirrors that redirect requests to them.
When you build, Maven resolves each dependency by looking in the local repository first, then in the configured remote repositories, and caches whatever it downloads locally.
The local repository is a cache on your machine, by default at ~/.m2/repository. Every downloaded artifact is stored under a path built from its coordinates, for example org/apache/commons/commons-lang3/3.14.0/commons-lang3-3.14.0.jar.
Running mvn install also puts your own project's artifact there so that other local projects can depend on it. Change the location in ~/.m2/settings.xml:
You can also pass -Dmaven.repo.local=/path for a single build, which is common in CI.
A remote repository is served over HTTPS. Maven Central is built into every Maven installation as the repository with id central, so most dependencies resolve without any configuration. Plain HTTP repositories are blocked by default since Maven 3.8.1, so use HTTPS URLs.
Declare an extra repository in a pom.xml when a library is not on Central:
Plugins are fetched from pluginRepositories, which is configured the same way.
| Type | Where | Purpose |
|---|---|---|
| Local | Your machine | Cache of downloaded and installed artifacts |
| Central | repo.maven.apache.org | Public default repository |
| Remote or third party | Another server | Vendor or project specific artifacts |
| Internal or private | Your organisation | Company artifacts and proxied public ones |
Releases are immutable versions such as 1.4.0. Snapshots (1.5.0-SNAPSHOT) are development builds that can change, and Maven checks for updates to them on a schedule.
groupId, artifactId, version) of the dependency.If a download fails, Maven records the failure and does not retry until the update interval passes. Force a refresh with mvn -U.
Organisations usually run a repository manager such as Sonatype Nexus Repository or JFrog Artifactory. It proxies Maven Central, caches artifacts, hosts internal releases and gives you one URL to control. Route all traffic through it with a mirror in settings.xml:
Put credentials in the servers section of settings.xml, matched by repository id, and never in the pom.xml.
Use mvn install to publish to the local repository and mvn deploy to publish to a remote one. Deployment needs a distributionManagement section:
Publishing to Maven Central goes through the Central Portal, which requires signed artifacts, a source JAR, a Javadoc JAR and complete POM metadata.
By default ~/.m2/repository on Linux and macOS, and C:\Users\<name>\.m2\repository on Windows. Override it with localRepository in settings.xml.
Common causes are a wrong version, a library hosted in a repository you did not declare, missing credentials, or a cached failure. Check the coordinates and run mvn -U.
A repository is where artifacts live. A mirror is a replacement URL that Maven uses instead of one or more repositories.
Yes. Maven downloads what it needs again, though the next build is slower.
Maven uses a local cache, remote repositories such as Central, and optional mirrors or repository managers to resolve and publish artifacts. Keep HTTPS URLs, store credentials in settings.xml, use a repository manager for teams, and remember that releases are immutable while snapshots can change.