19

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

3
  • Are you running from terminal or from an ide? perhaps try maven clean install Commented Oct 22, 2014 at 11:33
  • 1
    does the dependency (or a previous version of it) appear in your local .m2 repository? Commented Oct 22, 2014 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! Commented Oct 22, 2014 at 11:59

8 Answers 8

27

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.

Sign up to request clarification or add additional context in comments.

Comments

26

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

3 Comments

This fixed my problem. Any idea what's up with that?
I have added more information to the answer, with a more proper way to resolve the issue. Removing the dependency from <dependencyManagement> block as in the original answer wasn't really a good idea, since there could be other pom.xmls that depend on it.
Sheesh. That saved me from sure insanity.
7

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.

Comments

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!

1 Comment

I encounted this same problem and after rm -rf ~/.m2 and mvn -U clean pacakge, everything works!
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.

Comments

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.

Comments

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.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.