# Dependency convergence error for com.google.guava:guava:jar:30.1-jre paths to dependency are:

- **ID:** `java/maven-enforcer-dependency-convergence`
- **Domain:** java
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

Multiple versions of the same dependency (e.g., Guava) are resolved in the dependency tree with different versions, violating the Maven Enforcer plugin's dependency convergence rule, which requires a single version per artifact.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Maven 3.8 | active | — | — |
| Maven 3.9 | active | — | — |
| maven-enforcer-plugin 3.0.0 | active | — | — |
| maven-enforcer-plugin 3.1.0 | active | — | — |

## Workarounds

1. **Add a <dependencyManagement> section in the parent pom.xml to force a specific version of the conflicting artifact. Example:
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>31.1-jre</version>
    </dependency>
  </dependencies>
</dependencyManagement>** (90% success)
   ```
   Add a <dependencyManagement> section in the parent pom.xml to force a specific version of the conflicting artifact. Example:
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>31.1-jre</version>
    </dependency>
  </dependencies>
</dependencyManagement>
   ```
2. **Use the Maven Enforcer plugin's dependencyConvergence rule with excludes for known unavoidable conflicts:
<execution>
  <id>enforce</id>
  <configuration>
    <rules>
      <dependencyConvergence>
        <excludes>
          <exclude>com.google.guava:guava</exclude>
        </excludes>
      </dependencyConvergence>
    </rules>
  </configuration>
</execution>** (85% success)
   ```
   Use the Maven Enforcer plugin's dependencyConvergence rule with excludes for known unavoidable conflicts:
<execution>
  <id>enforce</id>
  <configuration>
    <rules>
      <dependencyConvergence>
        <excludes>
          <exclude>com.google.guava:guava</exclude>
        </excludes>
      </dependencyConvergence>
    </rules>
  </configuration>
</execution>
   ```
3. **Run 'mvn dependency:tree' to identify all paths and then add explicit <exclusions> in the specific dependency that brings the unwanted version.** (80% success)
   ```
   Run 'mvn dependency:tree' to identify all paths and then add explicit <exclusions> in the specific dependency that brings the unwanted version.
   ```

## Dead Ends

- **Remove the enforcer plugin entirely from the pom.xml** — This suppresses the build error but leaves the classpath with multiple versions, which can cause NoSuchMethodError or ClassCastException at runtime. (90% fail)
- **Manually exclude all conflicting transitive dependencies one by one** — This is tedious and error-prone; missing one exclusion still causes the error. It's better to use dependency management. (70% fail)
- **Use the latest version of the dependency in all places** — Simply using the latest version may introduce breaking changes from incompatible APIs; requires careful testing. (60% fail)
