Maven Compile "package ... does not exist" - Fix Classpath in CI
javac could not find a package referenced by your code because the library providing it is not on the compile classpath. The dependency is missing, declared at the wrong scope, or a sibling module was not built.
What this error means
The compile goal fails with package com.example.x does not exist and cannot find symbol for classes in that package. Compilation stops before tests run.
[ERROR] /workspace/src/main/java/com/example/App.java:[5,23]
package com.acme.util does not exist
[ERROR] cannot find symbol: class HelperCommon causes
Dependency missing or at the wrong scope
The library is not declared, or it is test/provided/runtime scope when the main code needs it at compile scope, so the package is invisible to javac.
Sibling module not built
In a multi-module build, the module providing the package was not built/installed first, so its classes are absent from the compile classpath.
How to fix it
Declare the dependency at compile scope
Add the library so the package is on the main compile classpath (default scope is compile).
<dependency>
<groupId>com.acme</groupId>
<artifactId>util</artifactId>
<version>1.4.0</version>
</dependency>Build required modules together
For multi-module builds, build the target module with its upstream modules.
mvn -B -pl :app -am clean installHow to prevent it
- Declare compile-time libraries at compile scope, build multi-module projects with
-am, and verify scopes withmvn dependency:tree.