Maven Enforcer "Rule failed" / "Failed with message" - Fix in CI
The maven-enforcer-plugin failed the build because a project invariant it guards was violated - a banned or convergent dependency conflict, or a required Java/Maven version not met. This is a guardrail working as intended.
What this error means
The build fails (often in the validate phase) with Some Enforcer rules have failed and a specific rule name like DependencyConvergence, RequireJavaVersion, or BannedDependencies, plus the offending detail.
[ERROR] Rule 1: org.apache.maven.enforcer.rules.dependency.DependencyConvergence
failed with message:
Failed while enforcing releasability.
Dependency convergence error for com.fasterxml.jackson.core:jackson-databind:
2.15.0 paths to dependency are: ...
[ERROR] Some Enforcer rules have failed.Common causes
Conflicting transitive versions (convergence)
Two paths pull different versions of the same dependency. DependencyConvergence fails the build until you pin one version.
Banned dependency or unmet version requirement
A BannedDependencies rule hit a forbidden artifact, or RequireJavaVersion/RequireMavenVersion found the running toolchain below the required floor.
How to fix it
Converge the conflicting dependency
Pin the conflicting library to one version via dependencyManagement so all paths agree.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.1</version>
</dependency>
</dependencies>
</dependencyManagement>Meet the required version or remove the banned dep
- For
RequireJavaVersion, provision the required JDK in CI with setup-java. - For
BannedDependencies, replace or exclude the forbidden artifact. - Inspect conflicts with
mvn dependency:tree -Dverbosebefore changing versions.
How to prevent it
- Manage versions centrally in dependencyManagement so convergence holds.
- Run
mvn dependency:tree -Dverboseto find conflicting paths early. - Treat enforcer failures as real violations, not noise to suppress.