Maven "Could not resolve dependencies" - Fix in CI
Maven walked your dependency tree and could not find one of the artifacts in any configured repository. Either the coordinates are wrong, the artifact lives on a repo Maven is not configured to use, or it was never published.
What this error means
The build fails during dependency resolution with Could not resolve dependencies for project ... and a Could not find artifact line naming the exact groupId:artifactId:version it could not locate. Nothing compiles because resolution aborts first.
[ERROR] Failed to execute goal on project app: Could not resolve dependencies
for project com.example:app:jar:1.0.0: Could not find artifact
com.example:lib:jar:2.3.1 in central (https://repo.maven.apache.org/maven2)Common causes
Wrong coordinates or a non-existent version
A typo in groupId/artifactId, or a version that was never published, means no repository has the artifact. Maven Central is case- and version-exact.
Artifact lives on a repository Maven is not configured for
Internal or third-party libraries often live on a private Nexus/Artifactory or a vendor repo. Without that <repository> declared (or a mirror configured), Central has nothing to serve.
A transitive dependency is unreachable
The missing artifact may be pulled in transitively. The direct dependency resolves, but one of its own dependencies is not on any reachable repo.
How to fix it
Verify the coordinates and find the real repo
- Confirm groupId:artifactId:version exactly against the artifact on Maven Central or your registry.
- Run with
-X(debug) to see every repository Maven queried and which one is missing the file. - If it is an internal artifact, add the hosting repository to the POM or settings.xml.
Declare the hosting repository
Point Maven at the repository that actually holds the artifact.
<repositories>
<repository>
<id>company-releases</id>
<url>https://nexus.example.com/repository/maven-releases/</url>
</repository>
</repositories>Force a clean re-resolve
Rule out a corrupted local cache by re-resolving without the partial download.
mvn -U dependency:resolve
# -U forces a check for updated releases/snapshotsHow to prevent it
- Pin a known-good version and keep internal repos declared in settings.xml, not ad hoc.
- Use a single mirror/proxy repo (Nexus, Artifactory) so every artifact resolves through one URL.
- Cache
~/.m2/repositoryin CI keyed on the POM so resolution is stable and fast.