I have a Maven project. When I try to build it with Maven, I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
3.2:compile (default-compile) on project myProject: Compilation failure:
Compilation failure:
[ERROR] ClassA.java:[32,38] cannot access ClassB
[ERROR] class file for ClassB not found
ClassB
is inside another artifact, and that artifact is in the local repository. In fact, I have no problems building this project with the m2eclipse Maven plugin. It's only when I run mvn compile
that the build fails.
What do I have to do to build from the command line?
The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax. tools. JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse.
Eclipse might be bypassing your pom dependencies and 'helping' you by finding a dependency that is not in your pom. Then when you run from command line eclipse isn't there to help anymore. I would double check your pom that you explicitly state dependency. You can also try
mvn dependency:analyze
for more info.
That looks like you have defined a usual class within the src/test/java instead of the src/main/java area which is sometimes the problem cause the eclipse things behaves a little bit different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With