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.)

Sae1962
  • 1,122
  • 15
  • 31
Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192

5 Answers5

119

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

Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • 4
    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. – Joni Aug 26 '11 at 09:16
  • 9
    there no option of `Update Snapshots` in my eclipse indigo , do u have any idea how to do in that – Hunt May 07 '13 at 16:28
  • 3
    @Hunt You can select the checkbox "Update Snapshots" in the maven build configuration in eclipse to have the dependencies updated. – Gaʀʀʏ Nov 15 '13 at 16:33
  • 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. – Gonzalo Aguilar Delgado Apr 20 '16 at 18:53
  • 1
    @Hunt in newer eclipse there is option of "Update Project". – TechnoCrat Dec 05 '17 at 07:08
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")

Roland Schneider
  • 3,615
  • 3
  • 32
  • 43
  • 3
    I am using eclipse Kepler. I had to check "Force Update of Snapshots/Releases" to fix the problem. Thx! – arun Jul 24 '14 at 23:19
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.

Eugene Ryzhikov
  • 17,131
  • 3
  • 38
  • 60
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.

Roland Schneider
  • 3,615
  • 3
  • 32
  • 43
lkisac
  • 2,007
  • 1
  • 26
  • 31
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

Nitin Dandriyal
  • 1,559
  • 11
  • 20
  • I tried the higher rated solutions and none of them worked. This was what worked for me, thanks. – DS. Jun 25 '18 at 10:36