views:

38

answers:

2

From what I have read, after adding the relevant maven repositories, maven should automatically download the necessary jars to satisfy dependencies in the pom.xml file.

However, no jars ever get downloaded for me after I add dependencies in eclipse. Am I missing some glaringly obvious step?

+1  A: 

Dependencies jars aren't in your project but in your local maven repository.

These jars will be automatically used when you compile you project with maven (or m2eclipse).

If you don't have the needed jar yet, maven will download it for you.

Colin Hebert
But the jars aren't getting added to my local repository...?
Finbarr
What is the output when you build your application ? If there is any problem, maven should tell you what it is.
Colin Hebert
When I run as maven build it just says build success. I can't actually compile my application just now because the code is dependent on certain jars that I am trying to have maven manage unsuccessfully.
Finbarr
I just noticed that there is some kind of error in the pom.xml file "missing artifact [the artifact I want to use]".
Finbarr
If your application builds successfully, then you don't have to worry about anything. Maven automatically download dependencies when they are needed. Either it builds successfully and everything is okay, or it doesn't and then you have a problem. EDIT : What is the artifact with a problem ? Can you give your pom.xml configuration.
Colin Hebert
Are you behind proxy?
Eugene Kuleshov
Not behind a proxy. I am reinstalling eclipse and starting from scratch as there was some kind of problem with updating installed software.
Finbarr
Everything worked after I reinstalled eclipse. Something must have messed up.
Finbarr
+2  A: 

I'd recommend to start from creating your project with m2eclipse. See more details in this article.

Basically, you need to make sure the following:

  • your Eclipse project has a valid pom.xml and all dependencies are available (you should see errors on Maven console, in the Problems or Markers view or when opening pom.xml in m2eclipse's POM editor)
  • Maven support is enabled for this project (you can use Maven / Enable Dependency Management from popup menu on that project)
  • project configuration is in sync with pom.xml (you can use Maven / Update Project Configuration from the project popup menu)
  • you can also use Maven / Update Dependencies to refresh your dependencies (e.g. when you got them in your Local Maven repo from the command line)
Eugene Kuleshov
After OP comments in my answer, I'm afraid he only has bad dependencies or a bad configuration.
Colin Hebert