15

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

Gab
  • 7,869
  • 4
  • 37
  • 68
S Singh
  • 1,403
  • 9
  • 31
  • 47
  • Are you running from terminal or from an ide? perhaps try `maven clean install` – Hagai Oct 22 '14 at 11:33
  • 1
    does the dependency (or a previous version of it) appear in your local .m2 repository? – Hagai Oct 22 '14 at 11:39
  • @Hagai yes, it is! that jar same version was downloaded for other projects but, i was needed to that in my project class path in mavens way! Now I resolved issue and also posted here what I tried! – S Singh Oct 22 '14 at 11:59

8 Answers8

25

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.

Dónal Boyle
  • 3,049
  • 2
  • 25
  • 40
24

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

Andrew Santosa
  • 271
  • 2
  • 7
  • This fixed my problem. Any idea what's up with that? – alext Aug 30 '19 at 07:23
  • I have added more information to the answer, with a more proper way to resolve the issue. Removing the dependency from `` block as in the original answer wasn't really a good idea, since there could be other `pom.xml`s that depend on it. – Andrew Santosa Aug 31 '19 at 15:24
  • Sheesh. That saved me from sure insanity. – SriniMurthy Jul 04 '23 at 02:45
6

I resolved this issue by following steps:

1). Remove concerned jar from local /m2 folder. 2). Run mvn eclipse:eclipse command 3). And last run: mvn clean install

Now I am looking for concerned jar in my project class path!

xmlParser
  • 1,903
  • 4
  • 19
  • 48
S Singh
  • 1,403
  • 9
  • 31
  • 47
6

If you are using IntelliJ Idea as your editor then simply follow 3 simple steps:

  1. Right click on your project
  2. Select Maven (last option probably)
  3. Select "Reload project"

And that's it, IntelliJ Idea will download the dependencies and now you can proceed further.

Shaikh Nazish
  • 169
  • 1
  • 4
1

Try:

Menu -> Project -> Clean -> Select the project

Right Click on the project -> Maven -> Maven clean

Right Click on the project -> Maven -> Maven install

Happened to me and it has fixed my problem. Hope it helps you.

0

I deleted .m2 folder and then from eclipse ran maven install then took maven update project. It resolved my issue and jar file got downloaded.

0

You can usually resolve these errors by updating Maven dependencies as follows:

Right-click on your top-level project (not on the pom.xml file) in the Project Explorer view. From the menu, choose Maven > Update project

Make sure ForceUpdate of Snapshots/Releases is checked, and click OK.

You'll see a progress indicator in the lower-right-hand corner of the application window. When the update completes, you should be able to generate code normally, and the error markers should disappear.

0

In IntelliJ

Right-click on your root folder of the project in the Project Explorer view. From the menu, choose Maven > Reload project.

After that, your new dependencies will be downloaded. Then you should be able to generate code normally, and all the error markers will disappear.

Pranav Choudhary
  • 2,726
  • 3
  • 18
  • 38