Maven duplicate dependency declaration error in CI
Maven's model validation found two <dependency> entries with the same groupId, artifactId, type, and classifier. The duplicate is ambiguous, so the build is blocked in validation.
What this error means
mvn fails with "'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: group:artifact:jar -> version vs version @ line N".
mvn output
[ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique:
org.apache.commons:commons-lang3:jar -> duplicate declaration of version 3.13.0 @ line 41, column 17Common causes
The same coordinate is declared twice
Two <dependency> blocks share group, artifact, type, and classifier, so Maven cannot pick one deterministically.
A merge added a second copy
A bad merge or copy-paste introduced a duplicate dependency the validator rejects.
How to fix it
Remove the duplicate declaration
- Open the POM at the reported line.
- Delete the redundant
<dependency>block, keeping the version you want. - Re-run
mvn validateto confirm uniqueness.
Terminal
mvn -B validateCentralize the version to avoid repeats
Manage the version once in dependencyManagement so contributors do not re-declare it with a version.
pom.xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
</dependencies>
</dependencyManagement>How to prevent it
- Resolve merge conflicts in the dependencies block carefully.
- Manage versions centrally to discourage re-declaration.
- Run
mvn validatebefore pushing POM edits.
Related guides
Maven "'dependencies.dependency.version' is missing" in CIFix Maven "'dependencies.dependency.version' for X is missing" in CI - a dependency has no version and none i…
Maven "Non-parseable POM" XML error in CIFix Maven "Non-parseable POM ... unexpected end of stream / must be terminated by the matching end-tag" in CI…
Maven "cyclic reference" in the reactor in CIFix Maven "The projects in the reactor contain a cyclic reference" in CI - two or more modules depend on each…