# 发现依赖 'com.google.guava:guava' 版本冲突：30.1.1-jre 与 31.0.1-jre。请使用依赖约束或强制指定版本。

- **ID:** `java/gradle-dependency-version-conflict`
- **领域:** java
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

项目中不同模块需要相同依赖的不同版本，导致冲突。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 8+ | active | — | — |

## 解决方案

1. **Force a specific version using Gradle's resolution strategy** (95% 成功率)
   ```
   configurations.all { resolutionStrategy.force 'com.google.guava:guava:31.0.1-jre' }
   ```
2. **Add a dependency constraint in build.gradle** (90% 成功率)
   ```
   dependencies { constraints { implementation('com.google.guava:guava:31.0.1-jre') } }
   ```

## 无效尝试

- **Removing one of the conflicting dependencies without checking transitive dependencies** — The transitive dependency may still pull in the conflicting version. (85% 失败率)
- **Using compileOnly scope on one dependency** — compileOnly does not resolve the conflict at runtime; it only affects compilation. (80% 失败率)
