# 在项目 my-app 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) 失败：编译失败：找不到模块 com.example.util

- **ID:** `java/maven-plugin-execution-error`
- **领域:** java
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Java 模块系统需要显式模块声明，并且所需的模块缺失或未在 module-info.java 中声明。

## 版本兼容性

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

## 解决方案

1. **Add the required module to module-info.java** (95% 成功率)
   ```
   module my.app { requires com.example.util; }
   ```
2. **Use --add-modules compiler argument if module is on classpath** (80% 成功率)
   ```
   <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><compilerArgs><arg>--add-modules</arg><arg>com.example.util</arg></compilerArgs></configuration></plugin>
   ```

## 无效尝试

- **Removing module-info.java entirely** — The project may be designed for Java 9+, and removing module-info can break encapsulation. (70% 失败率)
- **Adding the module to the classpath instead of module path** — Maven compiler plugin may still enforce module path for Java 9+. (80% 失败率)
