How to update maven repository in Eclipse?
Asked Answered
K

5

99

Assuming you're already using the m2eclipse plugin, what can you do when it doesn't update the dependencies to the latest in your repo?

For example, on the command line, you can just add the -U flag as in

mvn clean install -U 

…to force the dependencies to be updated. Is there something like this within Eclipse? (It doesn't always seem to pick up the latest updates.)

Kulun answered 31/3, 2010 at 19:24 Comment(0)
S
119

You can right-click on your project then Maven > Update Project..., then select Force Update of Snapshots/Releases checkbox then click OK.

Subacid answered 31/3, 2010 at 20:21 Comment(5)
This isn't completely same as -U: When you have old metadata file that references to a version that does not exist in repositories, updating snapshots doesn't work. In this situation you have to check what maven binary eclipse is using and run in console /path/to/bin/mvn clean install -U to get updated metadata file.Tankersley
there no option of Update Snapshots in my eclipse indigo , do u have any idea how to do in thatParks
@Parks You can select the checkbox "Update Snapshots" in the maven build configuration in eclipse to have the dependencies updated.Arborescent
In fact not always work. I have to change the version number to a wrong number and then changet it again to the right version to make it work.Turpentine
@Parks in newer eclipse there is option of "Update Project".Tolmach
B
48

In newer versions of Eclipse that use the M2E plugin it is:

Right-click on your project(s) --> Maven --> Update Project...

In the following dialog is a checkbox for forcing the update ("Force Update of Snapshots/Releases")

Baalbeer answered 1/7, 2014 at 11:22 Comment(1)
I am using eclipse Kepler. I had to check "Force Update of Snapshots/Releases" to fix the problem. Thx!Iciness
A
28

Right-click on your project and choose Maven > Update Snapshots. In addition to that you can set "update Maven projects on startup" in Window > Preferences > Maven

UPDATE: In latest versions of Eclipse: Maven > Update Project. Make sure "Force Update of Snapshots/Releases" is checked.

Autotomize answered 1/4, 2010 at 1:33 Comment(0)
P
27

Sometimes the dependencies don't update even with Maven->Update Project->Force Update option checked using m2eclipse plugin.

In case it doesn't work for anyone else, this method worked for me:

  • mvn eclipse:eclipse

    This will update your .classpath file with the new dependencies while preserving your .project settings and other eclipse config files.

If you want to clear your old settings for whatever reason, you can run:

  • mvn eclipse:clean
  • mvn eclipse:eclipse

    mvn eclipse:clean will erase your old settings, then mvn eclipse:eclipse will create new .project, .classpath and other eclipse config files.

Photosphere answered 26/2, 2015 at 20:52 Comment(3)
It worked when I found "Force Update" was not working, thanks!Inestimable
Thanks I wanted a way without using m2e and this is itKarsten
Awesome! the :clean fixed it for me.Devon
G
2

If Maven update snapshot doesn't work and if you have Spring Tooling, one interesting way is to remove

  • Right-click on your project then Maven > Disable Maven Nature
  • Right-click on your project then Spring Tools > Update Maven Dependencies
  • After "BUILD SUCCESS", Right-click on your project then Configure > Convert Maven Project

Note: Maven update snapshot sometimes stops working if you use anything else i.e. eclipse:eclipse or Spring Tooling

Germinate answered 1/3, 2017 at 10:14 Comment(1)
I tried the higher rated solutions and none of them worked. This was what worked for me, thanks.Evanston

© 2022 - 2024 — McMap. All rights reserved.