mvn -U (update snapshots): Usage & Common CI Errors
Force a fresh check for updated SNAPSHOT and missing release artifacts.
The -U (or --update-snapshots) flag forces Maven to check remote repositories for newer SNAPSHOT versions and to retry artifacts previously marked as missing. It is the fix for a build stuck on a stale SNAPSHOT or a cached resolution failure.
What it does
By default Maven updates SNAPSHOTs once per day. -U overrides that, re-resolving SNAPSHOTs immediately and clearing the cached "not found" markers (the _remote.repositories / resolution-cache entries) that otherwise suppress retries.
Common usage
mvn -U package
mvn --update-snapshots verify
mvn -U -o package # invalid: -U needs network; -o forbids itCommon error in CI (and the fix)
Symptom: CI keeps resolving an old SNAPSHOT even after a new one was published, or a transient "could not find artifact" persists after the registry recovered. Cause: Maven cached the prior resolution for the day. Fix: add -U to force a fresh remote check. Note -U requires network access, so it cannot be combined with -o (offline) - pick one.