java build_error ai_generated true

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project my-app: Compilation failure: module not found: com.example.util

ID: java/maven-plugin-execution-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-08-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
9+ active

Root Cause

The Java module system requires explicit module declarations, and a required module is missing or not declared in module-info.java.

generic

中文

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

Workarounds

  1. 95% success Add the required module to module-info.java
    module my.app { requires com.example.util; }
  2. 80% success Use --add-modules compiler argument if module is on classpath
    <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>

Dead Ends

Common approaches that don't work:

  1. Removing module-info.java entirely 70% fail

    The project may be designed for Java 9+, and removing module-info can break encapsulation.

  2. Adding the module to the classpath instead of module path 80% fail

    Maven compiler plugin may still enforce module path for Java 9+.