4

I'm having a hard time trying to compile a project in Eclipse. It is a pretty big parent project with many subprojects.

Eclipse displays hundreds of errors about names that can't be resolved in some of the subprojects. When I open one of the offending files and hover the mouse over the import statement, I have the option "Fix setup", which offers to add a jar from my local maven repository to the build path. This fixes each single issue.

It would seem that the pom.xml files don't contain all needed dependencies, except the project compiles without problems in the command line with mvn compile. So, there's something wrong with Eclipse and I have no idea what it could be.

After searching here in SO, I tried mvn eclipse:clean eclipse:eclipse to recreate the classpath files, but that didn't help.

Any ideas are welcome.

erickrf
  • 2,069
  • 5
  • 21
  • 44
  • After recreating the classpath, refresh and clean all projects within Eclipse. – Schaka Aug 03 '15 at 19:43
  • Do you have m2e (Maven Integration) installed in Eclipse? When you right click on the project in Eclipse, do you get **Maven** as a sub-menu option? – E-Riz Aug 03 '15 at 20:57
  • Well, if you recreated .project & .classpath with that command you mentioned AND you refreshed like @Schaka mentioned and you still have errors complaining about unresolved errors you usually don't use m2e Maven Plugin for Maven & did not create a M2_REPO enviroment variable within eclipse which points to your repo. I would recommend using the plugin because it makes life easier for you ;). – Jan Aug 03 '15 at 21:08
  • I'm using Eclipse 4.4.2, it already has m2e by default (though I never did anything configuration-wise). I just checked and M2_REPO points to my local repository. – erickrf Aug 03 '15 at 21:49
  • 1
    I have just seen the same problem. I imported a maven project into eclipse and see unresolved type errors. However, I can ctrl-click on an unresolved type and eclipse takes me to the jar file resource in my Maven Dependencies list. A project clean doesn't fix the problem. I am using Eclipse 4.5.1 – Robin Coe Nov 10 '15 at 17:01

3 Answers3

0

As I commented above, I also saw this problem. I had cloned the remote repo at the command line and then imported it as an existing POM project into Eclipse. For some reason, even though the Maven Dependencies are shown to be in the Build Path, Eclipse doesn't resolve them when validating the source in the editor, although it can find them when using ctrl-click on an unresolved type. Weird.

I got around this problem by deleting the project and using eclipse's m2 git connector to pull down the project. And while I thought maven integration was part of Eclipse, it isn't all there. To pull down the remote project, I first had to add the m2 connector. Best answer for doing that is here Checkout Maven project from SCM - no connectors

Community
  • 1
  • 1
Robin Coe
  • 750
  • 7
  • 28
0

I had a similar issue, add this in the M2 run config

clean compile   eclipse:eclipse

Once the build was successful, i hit the refresh F5, and it was ok.

which sorted it

codevalid
  • 191
  • 1
  • 3
  • 8
0

Try deleting .settings and .classpath files from project these are created by eclipse . Then reimport the project into eclipse