Force Intellij IDEA to reread all maven dependencies

MavenIntellij Idea

Maven Problem Overview


How to force intellij idea to reread/update all dependencies specified in the pom file ?

Maven Solutions


Solution 1 - Maven

Press Ctrl+Shift+A to find actions, and input "reload", you will find the "Reload All Maven Projects".

On a Mac, use ++A instead.

Solution 2 - Maven

Open the "Maven Projects" tab/window and clicking the "Reimport All Maven Projects" in the upper left corner starts to reload all dependencies from their repositories. The status bar informs about the process.

What lets you think that this is not working correctly? Maybe any of the dependencies can't be load from the repository?

Solution 3 - Maven

There is also one useful setting that tells IntelliJ to check for new versions of dependencies even if the version numbers didn't change. We had a local maven repository and a snapshot project that was updated a few times but the version numbers stood the same. The problem was that IntelliJ/Maven didn't update this project because of the fixed version number.

To enable checking for a changed dependency although the version number didn't change go to the "Maven Projects" tab, select "Maven settings" and there activate "Always update snapshots".

Solution 4 - Maven

For IntelliJ IDEA 14.0

Project > [your project name] > right click > Maven > Reimport

Solution 5 - Maven

The leftmost button (blue cycle) below also reimports all maven projects:

enter image description here

Solution 6 - Maven

run this command mvn -U clean install

Solution 7 - Maven

If the reimport does not work (i.e. doesn't remove old versions of dependencies after a pom update), there is one more chance:

  • open the project settings (CTRL+SHIFT+ALT+S)
  • on modules, delete all libs that you want to reimport (e.g. duplicates)
  • IDEA will warn that some are still used, confirm
  • Apply and select OK
  • then reimport all maven projects.

Solution 8 - Maven

Setting > Maven > Always update snapshots

Solution 9 - Maven

In the latest IntelliJ IDEA version (2020.1.3 Ultimate Edition), You need to to click this little guy that appears on the top right of the editor window after you make a change to the pom.xml

This little guy is too small and in an unnoticeable position. I liked the previous versions where an alert shows up in the bottom right. Still can't find the option to enable auto import in this version.

enter image description here

Another Option

From the properties panel on the right, select Maven and click on the reload icon. If you do not see maven on right panel, open it from View > Tool Windows > Maven

enter image description here

Solution 10 - Maven

Go to File | Settings | Build, Execution, Deployment | Build Tools | Maven

Select "Always update snapshots"

Solution 11 - Maven

I had a problem where IntelliJ was unable to compile classes, claiming that dependencies between projects were missing. Reimporting the project as suggested in the answers of this question didn't solve the problem. The solution for me, was:

  1. remove all projects (project tab / right click on the root folder / maven / remove projects);
  2. close the editor;
  3. compile all projects with maven on the command line;
  4. open the editor on the same project;
  5. add the projects to maven again (maven tab / add maven projects (green +) / choose the root pom);

WARNING: on some projects, you might have to increment max memory for maven import (maven settings on maven tab / Importing / VM options for importer).

Solution 12 - Maven

If you are using version ranges for any dependencies, make sure that IntelliJ is using Maven 3 to import the project. You can find this setting in: Settings > Maven > Importing > Use Maven3 to import project. Otherwise you may find that SNAPSHOT versions are not imported correctly.

Solution 13 - Maven

If you work in IntelliJ, there are four independent ways to refresh maven repositories. Each of them refreshes another local repository on your computer or refreshes them differently.

1. mvn -U clean install
2. Ctrl+Shift+A - Reimport
3. Round arrows in the Maven window

4. Ctrl+Alt+S , go to Build, Execution, Deployment | Build Tools | Maven | Repositories -choose rep - update

What is interesting, it is often said, that the last refresh is equal to the round arrows in the Maven window. But, according to my experience, they are absolutely different! The proof: Our large project fails the last refresh, but exists and runs happily without it. And double round arrows run OK on it.

Each of these four can help you with your problems or/and find problems of its own. For example, for running our real-life project only the first is necessary, but for testing in IntelliJ we also need 2 and 3. Surely, somebody needs 4, too. (Why else IntelliJ has it?)

Solution 14 - Maven

To remove all dependencies you can simply delete your local maven repo: ~/.m2 folder by default. Then rebuild your projects one-by-one:

mvn clean
mvn package

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
Questionkubek2kView Question on Stackoverflow
Solution 1 - MavenJackyView Answer on Stackoverflow
Solution 2 - MavenmagomiView Answer on Stackoverflow
Solution 3 - MavenBjörn JacobsView Answer on Stackoverflow
Solution 4 - MaventeejayView Answer on Stackoverflow
Solution 5 - MavenUmut UzunView Answer on Stackoverflow
Solution 6 - MavenBabajide ApataView Answer on Stackoverflow
Solution 7 - MavenAndreas DolkView Answer on Stackoverflow
Solution 8 - Mavennobjta_9x_tqView Answer on Stackoverflow
Solution 9 - MavenDrunken DaddyView Answer on Stackoverflow
Solution 10 - MavenrsljView Answer on Stackoverflow
Solution 11 - MavenManuel RomeiroView Answer on Stackoverflow
Solution 12 - Mavenvegemite4meView Answer on Stackoverflow
Solution 13 - MavenGangnusView Answer on Stackoverflow
Solution 14 - Mavenuser8280225View Answer on Stackoverflow