Pawan
Pawan

Reputation: 32321

Maven project builds successfully in Eclipse, but shows compile errors in cmd prompt

I have imported an existing Maven project into Eclipse IDE. I modified some of the code and built the project in Eclipse. There are no build errors.

However, when I ran mvn clean install from the command prompt, it is showing a lot of compilation errors. Why is Eclipse not showing errors and whereas Maven shows compilation errors?

Upvotes: 4

Views: 6437

Answers (2)

kevinarpe
kevinarpe

Reputation: 21299

Building on TJR's answer, I want to give a concrete example that just happened to me.

I also had a build that "works" in Eclipse, but failed with many Java compiler errors on the command line. (Thankfully, I always test with 'mvn clean install' before doing a release.)

In my case, I had build some custom hamcrest matchers, but the hamcrest dependencies in my POM were set as: <scope>test</scope> Removing this scope restriction fixed my bug.

Seems like m2e still needs more work.

Upvotes: 1

TJR
TJR

Reputation: 3773

Eclipse doesn't have the concept of the maven scopes. Whereas maven will have different classpaths depending on the scope--eclipse will only have a single classpath set.

IMHO, I don't trust m2eclipse for builds--just let it assist with development.

Upvotes: 5

Related Questions