How to update maven repository in Eclipse?

JavaEclipseMaven 2BuildM2eclipse

Java Problem Overview


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

Java Solutions


Solution 1 - Java

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

Solution 2 - Java

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 - Java

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 - Java

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 - Java

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStephane GrenierView Question on Stackoverflow
Solution 1 - JavaPascal ThiventView Answer on Stackoverflow
Solution 2 - JavaRoland SchneiderView Answer on Stackoverflow
Solution 3 - JavaEugene RyzhikovView Answer on Stackoverflow
Solution 4 - JavalkisacView Answer on Stackoverflow
Solution 5 - JavaNitin DandriyalView Answer on Stackoverflow