# 编译失败：包 com.example.util 不存在

- **ID:** `java/maven-compilation-package-not-exists`
- **领域:** java
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

类路径中缺少必需的 Java 包，通常是由于缺少依赖或模块路径不正确。

## 版本兼容性

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

## 解决方案

1. **Add the correct dependency to pom.xml** (95% 成功率)
   ```
   <dependency><groupId>com.example</groupId><artifactId>example-utils</artifactId><version>1.0.0</version></dependency>
   ```
2. **Use mvn dependency:copy-dependencies to verify classpath** (80% 成功率)
   ```
   mvn dependency:copy-dependencies -DoutputDirectory=target/lib
   ```

## 无效尝试

- **Adding a random dependency with similar groupId but different artifactId** — The package name is specific to the correct artifact; a different artifact may not contain it. (90% 失败率)
- **Manually copying the jar file to the project's lib folder without updating pom.xml** — Maven does not automatically include local jars unless configured as system scope. (85% 失败率)
