Skip to content
Latchkey

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 17

Common 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

  1. Open the POM at the reported line.
  2. Delete the redundant <dependency> block, keeping the version you want.
  3. Re-run mvn validate to confirm uniqueness.
Terminal
mvn -B validate

Centralize 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 validate before pushing POM edits.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →