Eclipse cannot resolve maven dependencies but compiles project from command line

I find it difficult to compile a project in Eclipse. This is a fairly large parent project with many sub-projects.

Eclipse displays hundreds of naming errors that cannot be resolved in some subprojects. When I open one of the offending files and hover over the import statement, I have a "Fix setup" option that suggests adding a jar from my local maven repository to the build path. This fixes every single issue.

It would seem that the pom.xml files do not contain all the required dependencies, except that the project compiles without issue on the command line with mvn compile

. So something is wrong with Eclipse and I have no idea what it might be.

After searching here on SO, I tried to mvn eclipse:clean eclipse:eclipse

recreate the class files, but it didn't help.

Any ideas are appreciated.

+3


source to share


2 answers


As I noted above, I have seen this problem as well. I cloned the remote repo on the command line and then imported it as an existing POM project in Eclipse. For some reason, even though Maven Dependencies appear in the build path, Eclipse does not resolve them when checking the source in the editor, although it can find them when ctrl-clicking on the unresolved type. Weird.



I ran into this issue by deleting the project and using the eclipse m2 git connector to pull the project down. And while I thought maven integration was part of Eclipse, that's not all. To pull the remote project I first had to add the m2 connector. The best answer for this can be found here Maven Checkout Project by SCM - No Connectors

0


source


I had a similar problem, add this to your M2 launch config

clean compile   eclipse:eclipse

      



Once the build was successful, I hit the F5 update and everything was fine.

which sorted it

0


source







All Articles