Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven- not downloading new added dependency in pom.xml file

Tags:

java

maven

I need new third party jar for reading csv in maven based project. So, I did entry in pom.xml for same as below.

<dependency>
        <groupId>net.sf.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>2.0</version>
    </dependency>

But when I run mvn install or mvn package command, It does not download newly added dependency and just build project and generate war.

I am trying to get the issue! Please share solution if anybody face this earlier!

Regards

like image 677
S Singh Avatar asked Oct 22 '14 11:10

S Singh


People also ask

Why Maven dependencies are not getting downloaded?

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. See the Maven documentation for details of how to configure the HTTP proxy.


2 Answers

Try running a forced update:

mvn clean install -U

The -U (uppercase U) forces maven to look at all dependencies and try to update them.

like image 143
Dónal Boyle Avatar answered Nov 15 '22 19:11

Dónal Boyle


If the dependency is defined in a <dependencies> block that is within a <dependencyManagement> block, adding it without the version number to a <dependencies> block that is outside <dependencyManagement> may fix the problem.

This is because the purpose of <dependencyManagement> block is to manage dependency versions, and not to install the dependencies. See this other article: Differences between dependencyManagement and dependencies in Maven

like image 32
AndrewSantosa Avatar answered Nov 15 '22 21:11

AndrewSantosa