How to update maven repository in Eclipse?

267,386

Solution 1

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

Solution 2

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

Solution 3

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.

Solution 4

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.

Solution 5

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

Share:
267,386
Stephane Grenier
Author by

Stephane Grenier

Author of the book Blog Blazers. Blog author of FollowSteph.com Founder of LandlordMax Property Management Software

Updated on May 05, 2020

Comments

  • Stephane Grenier
    Stephane Grenier about 4 years

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

  • Joni
    Joni almost 13 years
    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.
  • Hunt
    Hunt about 11 years
    there no option of Update Snapshots in my eclipse indigo , do u have any idea how to do in that
  • Gaʀʀʏ
    Gaʀʀʏ over 10 years
    @Hunt You can select the checkbox "Update Snapshots" in the maven build configuration in eclipse to have the dependencies updated.
  • arun
    arun almost 10 years
    I am using eclipse Kepler. I had to check "Force Update of Snapshots/Releases" to fix the problem. Thx!
  • Leon Chen
    Leon Chen almost 9 years
    It worked when I found "Force Update" was not working, thanks!
  • sam
    sam over 8 years
    Thanks I wanted a way without using m2e and this is it
  • Gonzalo Aguilar Delgado
    Gonzalo Aguilar Delgado about 8 years
    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.
  • Erwin Lengkeek
    Erwin Lengkeek over 7 years
    Awesome! the :clean fixed it for me.
  • TechnoCrat
    TechnoCrat over 6 years
    @Hunt in newer eclipse there is option of "Update Project".
  • DS.
    DS. almost 6 years
    I tried the higher rated solutions and none of them worked. This was what worked for me, thanks.