Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven not downloading dependencies in Eclipse

I am setting up a project in eclipse . This projects builds successfully through command line(all mvn commands like mvn package, mvn compile, mvn clean install) work perfectly fine. While setting up this project on STS or Eclipse . I see some of the dependencies are not getting downloaded even though they are present in pom.xml. However, searching them in the maven repository and downloading the jar to my local computer and then adding them to build path makes it work on Eclipse.

Is there anything that we need to do to eclipse to make sure it downloads all the dependencies from the repository.

My POM:

<dependency>     <groupId>org.apache.bookkeeper</groupId>     <artifactId>bookkeeper-server-compat410</artifactId>     <version>4.1.0</version>     <scope>test</scope>     <exclusions>         <exclusion>             <groupId>org.apache.bookkeeper</groupId>             <artifactId>bookkeeper-server</artifactId>         </exclusion>     </exclusions> </dependency> <dependency>     <groupId>org.apache.bookkeeper</groupId>     <artifactId>bookkeeper-server-compat420</artifactId>     <version>4.2.0</version>     <scope>test</scope>     <exclusions>         <exclusion>             <groupId>org.apache.bookkeeper</groupId>             <artifactId>bookkeeper-server</artifactId>         </exclusion>     </exclusions> </dependency> 

Both these artifacts were not downloaded for eclipse and there jars found http://mvnrepository.com/artifact/org.apache.bookkeeper/bookkeeper-server-compat410/4.1.0 and http://mvnrepository.com/artifact/org.apache.bookkeeper/bookkeeper-server-compat420/4.2.0 were not present in the folder for MavenDependencies and were subsequently giving errors in Eclipse.

enter image description here

However manually adding them to the build path created a new folder (Reference Library) and resolved the Eclipse Errors . Why did Eclipse not download and import these dependencies by themselves from the maven repository ?? Is it a bug in Eclipse or some problem from my side . Please help.

enter image description here

like image 913
Ankur Garg Avatar asked Jul 30 '15 09:07

Ankur Garg


People also ask

Why Maven dependencies are not getting downloaded?

Maven uses HTTP to download its dependencies along with the dependencies of the Maven project (such as Camel). If you run Maven and it fails to download your required dependencies it's likely to be caused by your local firewall & HTTP proxy configurations.

How do I force Maven to download dependencies in Eclipse?

Via the Maven index, you can search for dependencies, select them and add them to your pom file. To download the index, select Windows > Preferences > Maven and enable the Download repository index updates on startup option. After changing this setting, restart Eclipse. This triggers the download of the Maven index.


2 Answers

I got the same problem and this is how i solved. :

  1. Right click your project, choose Run As -> Maven install. Observe the output console to see the installation progress. After the installation is finished, you can continue to the next step.

enter image description here

enter image description here

  1. Right click your Spring MVC project, choose Maven -> Update Project.

enter image description here

  1. Choose your project and click OK. Wait until update process is finished.
  2. The error still yet, then do Project->Clean and then be sure you have selected our project directory and then do the follow Project->Build.
like image 118
Saket Mittal Avatar answered Sep 25 '22 07:09

Saket Mittal


Solution 1:

Set correct proxy:

<proxy>     <id>optional</id>     <active>false</active>     <protocol>http</protocol>     <username></username>     <password></password>     <host>172.27.171.91</host>     <port>8080</port> </proxy> 

Solution2 :

just delete

lastupdated extension files from folder 

and try updating maven.

[Most of the times this solution will work]

like image 26
VeKe Avatar answered Sep 25 '22 07:09

VeKe