This host proxies and caches artifacts from
repo.maven.apache.org (Central). Point Maven or Gradle here
to speed up dependency resolution and cut outbound traffic. Replace
mirror.example.com below with this server's actual hostname.
Redirect all repository requests through the mirror by adding a
<mirror> entry to your user-level settings, usually
~/.m2/settings.xml.
<settings>
<mirrors>
<mirror>
<id>mirror</id>
<mirrorOf>*</mirrorOf>
<url>https://mirror.example.com/maven2</url>
</mirror>
</mirrors>
</settings>
<mirrorOf>*</mirrorOf> catches every
configured repository. Narrow it to
central if you only want Central requests mirrored.
Scope the mirror to a single project and commit it, so every
teammate and CI job resolves through the mirror automatically — no
local settings.xml edits required.
<repositories>
<repository>
<id>mirror</id>
<url>https://mirror.example.com/maven2</url>
</repository>
</repositories>
This adds the mirror as an extra repository rather than
replacing Central outright — use the settings.xml
<mirror> approach if you need a strict, project-wide
override.
repositories {
maven { url 'https://mirror.example.com/maven2' }
}
repositories {
maven("https://mirror.example.com/maven2")
}
No repo pom.xml changes needed — point Maven at a pipeline-provided settings file.
mvn -s ci-settings.xml -B verify
mvn help:effective-settings | grep -A2 mirror
curl -s https://mirror.example.com/maven2/ -o /dev/null -w "%{http_code}\n"
# resolve something and time it
time mvn dependency:get -Dartifact=com.google.guava:guava:33.0.0-jre
| Check | Expected result |
|---|---|
mvn help:effective-settings | Lists mirror.example.com under <mirrors> |
GET /maven2/ | 200 — mirror is reachable |
| First resolve of an artifact | Slower — cache miss, fetched from upstream and stored |
| Repeat resolve | Fast — served from local ~/.m2/repository cache |
repo.maven.apache.org.
mvn deploy still goes straight to the real repository
defined in your <distributionManagement> — this
mirror only accelerates dependency resolution. SHA-1/SHA-256 checksum
verification against the recorded artifact hash still applies
regardless of which source served the bytes.