Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

m2eclipse says "Missing artifact" but I can build from cmdline!

I'm trying to use this Sonatype Eclipse plugin for the first time to handle an existing (huge) software that I can build with maven form the command line.

I have configured the plugin to use my maven 2.2.1 installation instead of the built-in Maven 3.

In Eclipse I have 25 projects (loaded through the root pom.xml) and 4 of them have compilation errors; the maven console contains a lot of lines like this one:

Missing artifact commons-logging:commons-logging:jar:1.0.4:compile

I have all the jars in my repository and the M2_REPO classpath variable correctly defined. Why the plugin doesn't see all the jars?

The .classpath file of those projects simply references "MAVEN2_CLASSPATH_CONTAINER", there isn't a list of the jars. The pom.xml in Eclipse shows an error on the first line for the missing jars but I can build from the command line!

Any idea? I need help! I will try to move to NetBeans if I don't solve this problem.

Thank you.

like image 763
Pino Avatar asked Mar 31 '11 13:03

Pino


People also ask

How do I fix Maven dependency problem in STS?

Right-click on the project and choose Properties, and then Maven. Uncheck the box labeled "Resolve dependencies from Workspace projects" Hit Apply, and then OK. Right-click again on your project and do a Maven->Update Snapshots (or Update Dependencies)

What is artifact file in Maven?

In Maven terminology, an artifact is an output generated after a Maven project build. It can be, for example, a jar, war, or any other executable file. Also, Maven artifacts include five key elements, groupId, artifactId, version, packaging, and classifier.


2 Answers

You may need to to tell Eclipse to force update:

Project -> Maven -> Update Maven Project 

and then make sure you have selected:

Force Updates of Snapshots/Releases 

this happens when mvn install copies some jar files into Maven repository and Eclipse had checked this repo BEFORE this jar has been copied there.

like image 82
Damian Avatar answered Oct 01 '22 16:10

Damian


If Dependency management is enabled when the above problems occur in Eclipse you can Project > Maven > Disable Dependency Management and then \Project > Maven > Enable Dependency Management. This normally remove any dependency errors in the pom.xml.

Also do as @Nishant indicated in his answer above after the above steps to complete the projects dependencies.

like image 39
Jurie Avatar answered Oct 01 '22 16:10

Jurie