/commands/maven/mvn-versions-display-dependency-updates
mvn versions:display-dependency-updates: check for newer Maven dependencies
- tool
- Maven
- versions
- Maven 3.x, versions-maven-plugin 2.x
- os
- any
mvn versions:display-dependency-updates lists every dependency in pom.xml for which a newer version exists in the configured repositories, as group:artifact ... current -> newest. It is read-only. The goal belongs to the Versions Maven Plugin from MojoHaus, which Maven resolves through the versions prefix without any POM change. Companion goals report plugin updates and property-based versions, and others can rewrite the POM for you.
Usage
mvn versions:display-dependency-updates
mvn versions:display-plugin-updates # newer versions of build plugins
mvn versions:display-property-updates # versions held in <properties>
mvn versions:display-dependency-updates -Dversions.outputFile=updates.txt
mvn org.codehaus.mojo:versions-maven-plugin:2.23.0:display-dependency-updates # pin the plugin versionRun it from the folder with pom.xml. In a multi-module build it reports each module; dependencies managed in a parent's dependencyManagement are reported where they are declared.
Goals of the Versions plugin
| Goal | What it does |
|---|---|
| versions:display-dependency-updates | Report newer versions of dependencies (read-only) |
| versions:display-plugin-updates | Report newer plugin versions and missing plugin version pins |
| versions:display-property-updates | Report newer versions for versions defined as properties |
| versions:use-latest-releases | Rewrite dependencies to the latest release versions |
| versions:use-next-releases | Rewrite to the next release only |
| versions:update-properties | Rewrite version properties to the latest versions |
| versions:set -DnewVersion=1.2.0 | Change the project version (all modules) |
| versions:commit / versions:revert | Delete or restore the pom.xml.versionsBackup files |
Pitfalls
- Prereleases in the report. Without a version filter, alpha, beta, milestone and release candidate versions can appear as the newest. Configure ignored versions as described in the plugin documentation.
- Major versions. The report does not tell you whether an update is compatible. Spring, Jakarta and Hibernate major versions in particular need code changes; update them one at a time.
- BOMs. Versions imported from a BOM (for example
spring-boot-dependencies) are updated by changing the BOM version, not each artifact. - Plugin resolution errors. Without access to Maven Central or a mirror that proxies it, Maven fails with No plugin found for prefix 'versions'.
- Snapshots.
-DallowSnapshots=trueincludes snapshot versions; leave it off for release builds.
How to confirm it worked
The report ends with the list of updates, or with a line saying that all dependencies use their latest versions. After a rewriting goal, git diff pom.xml shows the change and mvn dependency:tree shows the versions Maven now resolves, including transitive ones.
FAQ
How do I ignore alpha, beta and milestone versions?
Pass a version filter, for example -Dmaven.version.ignore='.*-(alpha|beta|M|RC).*' with a recent plugin version, or configure ignored versions in the plugin's ruleSet. Otherwise prereleases can be reported as the newest version.
Does versions:display-dependency-updates change my pom.xml?
No. display-* goals only report. Goals such as versions:use-latest-releases or versions:update-properties edit the POM and keep a pom.xml.versionsBackup copy until you run versions:commit or versions:revert.
Why does it say No plugin found for prefix versions?
Maven could not resolve the plugin prefix, usually because the build has no access to Maven Central or a mirror blocks the plugin group. Use the full coordinates, org.codehaus.mojo:versions-maven-plugin:display-dependency-updates, and check settings.xml mirrors.