Maven: Could not resolve dependencies, was cached in the local repository
Maven caches failed resolutions in .lastUpdated markers. Force an update, declare the missing repository, and read the status code before purging.

Introduction & Quick Summary
[ERROR] Failed to execute goal on project app: Could not resolve dependencies for project
com.example:app:jar:1.0.0: The following artifacts could not be resolved:
org.example:shared:jar:2.1.0 (absent):
org.example:shared:jar:2.1.0 was not found in https://repo.maven.apache.org/maven2
during the period ... was cached in the local repository, resolution will not be reattempted
until the update interval of central has elapsed or updates are forcedTwo failures share this message: the artifact may be missing, or Maven cached a failure and will not retry until the update interval expires. The second is far more common after a repository is added or a proxy is fixed.
The four causes:
- A cached failure. Maven writes
*.lastUpdatedmarkers next to the missing artifact, and will not re-request until the interval passes or-Uis used. - The repository is not declared. A
settings.xmlmirror, a<repository>in a parent POM, or a corporate proxy that only allowscentral. - The artifact really does not exist. A wrong group or version, a snapshot that was never deployed, or a
classifiermismatch. - Offline or a broken local repo.
-o, a partially downloaded JAR, or a_remote.repositoriesfile that ties the artifact to a repository that no longer exists.
| Message fragment | Meaning | First fix |
|---|---|---|
was cached in the local repository | Failure marker present | mvn -U, or delete *.lastUpdated |
Could not find artifact ... in central | Not published to central | Declare the right repository |
(absent) | Resolver knows the coordinate but has no file | Check the version exists |
Could not transfer artifact ... 401 | Credentials for a private repository | settings.xml server entry |
was cached ... in offline mode | -o is set | Remove -o |
Core Mechanics, Signatures & Reproducible Setup
Maven resolves a dependency by trying each configured repository in order, then writing the artifact to ~/.m2/repository/<group path>/<artifact>/<version>/. On failure it writes <artifact>-<version>.jar.lastUpdated with the repository id and timestamp. That file is the cache of the failure, and it is why the same error returns instantly on the next build.
A reproduction is one POM with a coordinate that does not exist:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>app</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>shared</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
</project>mvn -q dependency:resolve
ls ~/.m2/repository/org/example/shared/2.1.0/
# shared-2.1.0.jar.lastUpdated# after the artifact is published or the repository is added
mvn -U dependency:resolve
ls ~/.m2/repository/org/example/shared/2.1.0/
# shared-2.1.0.jar shared-2.1.0.pom _remote.repositories-U forces a re-check of releases and snapshots once. It does not fix a coordinate that does not exist.
Key Comparison Table
The recovery flags differ in how much they throw away, and choosing the biggest one for a one-artifact problem wastes a full download.
| Command | Clears failure markers | Re-downloads | Scope | Typical use |
|---|---|---|---|---|
mvn -U | Yes, once per build | Missing and snapshot artifacts | Whole build | Added a repository |
rm ~/.m2/.../*.lastUpdated | Yes, for that artifact | That artifact | One coordinate | Stuck single dependency |
mvn -U dependency:purge-local-repository | Yes | All project dependencies | Project | Corrupt local repo |
mvn -o | No, disables network | Nothing | Whole build | Offline, already populated |
mvn -llr (legacy) | Yes, ignores _remote.repositories | As needed | Whole build | Maven 3.0 local repo layout |
mvn -Dmaven.repo.local=/tmp/m2 | Yes, fresh repository | Everything | Whole build | Isolating a corruption |
The local repository records which repository an artifact came from, which decides whether a resolution succeeds when that repository is gone.
| File in the version directory | Means | Effect when the repository disappears |
|---|---|---|
_remote.repositories | Artifact resolved from these repos | Resolution fails unless -llr is used |
*.lastUpdated | Last failed attempt and its timestamp | Resolution is skipped until the interval |
.part file | Interrupted download | Corrupt artifact, resolution fails |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
Force one artifact without purging everything
The narrow fix is to delete the failure markers for the coordinate and resolve again, which is fast in a large multi-module build.
find ~/.m2/repository/org/example/shared -name '*.lastUpdated' -delete
mvn -q -pl app dependency:resolve# inspect what the marker says before deleting it
cat ~/.m2/repository/org/example/shared/2.1.0/*.lastUpdated
# #NOTE: This is a Maven Resolver internal implementation file...
# https://repo.maven.apache.org/maven2/.error=
# https://repo.maven.apache.org/maven2/.lastUpdated=20261122071000The error= line is the HTTP status the repository returned, which distinguishes a 404 from a 401.
Declare the repository the artifact actually lives in
A dependency from JitPack, GitHub Packages, or an internal Nexus is not in Maven Central, and Maven will not guess. The repository must be in the POM or in settings.xml, and the id must match the one a mirror or server entry uses.
<repositories>
<repository>
<id>company-nexus</id>
<url>https://nexus.example.com/repository/maven-releases/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories><!-- ~/.m2/settings.xml -->
<settings>
<servers>
<server>
<id>company-nexus</id>
<username>${env.NEXUS_USER}</username>
<password>${env.NEXUS_PASSWORD}</password>
</server>
</servers>
<mirrors>
<mirror>
<id>company-nexus</id>
<mirrorOf>central</mirrorOf>
<url>https://nexus.example.com/repository/maven-public/</url>
</mirror>
</mirrors>
</settings>A mirror with <mirrorOf>*</mirrorOf> routes every repository, including one the build needs, through a single host. That is a frequent cause of Could not find artifact in CI when the mirror lacks a proxy rule.
Snapshots and the update policy
Snapshots are cached with an update interval, so a freshly deployed snapshot is invisible until the interval passes or -U is used. A CI job that must see the latest snapshot should always pass -U for that module.
<repository>
<id>snapshots</id>
<url>https://nexus.example.com/repository/maven-snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>mvn -U -pl service -am install -DskipTests-am builds the required modules from the reactor, which is usually better than pulling a half-published snapshot from a repository.
Multi-module reactors and the install step
A module that depends on a sibling's current version fails when the sibling is not installed and the reactor does not include it. The artifact exists in the source tree but not in the local repository.
# build the dependency chain
mvn -pl app -am dependency:resolve
# or install the parent and siblings first
mvn -q -DskipTests installUsing ${project.version} for sibling dependencies, plus -am, keeps the reactor consistent without hand-editing versions.
Credentials, proxies and TLS
A 401, a 404, and a proxy that intercepts TLS all surface as Could not resolve dependencies, so the status line in the error output is the decisive evidence.
# show the underlying transfer errors
mvn -U -e -X dependency:resolve 2>&1 | grep -iE "HTTP|401|403|404|handshake|protocol" | head -20<proxy>
<id>corp-proxy</id>
<active>true</active>
<protocol>https</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<nonProxyHosts>localhost|*.internal</nonProxyHosts>
</proxy>An old JDK that cannot negotiate TLS 1.2 produces Received fatal alert: protocol_version, which no repository configuration can fix; upgrading the JDK does.
Common Compilation/Runtime Mistakes & Version Gotchas
Running mvn clean install again. Clean removes target/, not the failure markers in ~/.m2, so the same cached failure returns.
Purging the whole local repository. rm -rf ~/.m2/repository fixes the problem and costs a full download of every dependency; delete the specific coordinate's markers instead.
Mixing -o with a dependency that is not cached. Offline mode reports the artifact as absent even when the repository has it. Read the in offline mode fragment before debugging the network.
Assuming a mirror and a repository are interchangeable. A mirror redirects an existing repository id; a repository adds a source. A build that needs both requires both.
Leaving -U in every build. It defeats the update interval and makes every build contact every repository. Use it when a dependency changed, not as a permanent flag.
Version notes. Maven 3.0's -llr flag was removed in later 3.x releases, so a script copied from an old guide fails on the option. Maven 3.9 changed how it warns about HTTP repositories, and Maven 4 defaults to blocking plain HTTP; both surface as resolution failures rather than warnings in strict builds. The _remote.repositories file has been written since Maven 3.0, so a lockfile-style local repository copied between machines can block resolution for artifacts that are present.
Order of work: read the failing coordinate and the repository URL from the error, -U once, then check whether the artifact exists in that repository at all. A direct request settles it fastest: fetch the POM with the curl builder, and compare the published SHA-1 against the local file with the hash tool when a checksum is the suspect.
Official references: Maven CLI options and Maven settings reference.
Official references
primary documentationThe Java documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Java work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Java guides
All Java guidesAndroid Gradle plugin requires Java 17 to run: where the JDK comes from
Gradle picks its JVM from several places. Make gradle.properties, JAVA_HOME, Studio and CI agree, and stop the stale daemon afterwards.
Spring Boot: Failed to configure a DataSource and no url attribute
The application never reached the database. The URL is missing, in the wrong file, or under a profile that is not active.
Maven: release version 25 not supported and where the JDK comes from
Six places choose the JDK and only one matters per build. Diagnose the release error, then pin the compiler so it cannot drift again.
Spring Boot 4: NoClassDefFoundError javax/servlet/http/HttpServlet
Spring Boot 4 runs Jakarta only. A library compiled against javax asks for a class that no longer exists, and the stack trace hides which jar.
More in Java
All Java guidesThe guides filed next to this one in Java, in library order.