How can I make IntelliJ IDEA update my dependencies from Maven?

MavenIntellij Idea

Maven Problem Overview


When I manually add dependencies in the pom.xml of my project, let Maven download the dependencies and let IntelliJ build the module, IntelliJ complains about missing libraries. At the same time Maven can find the dependent JARs and build the project.

How can I tell IntelliJ to use the libs which are downloaded by Maven?

Maven Solutions


Solution 1 - Maven

It turns out IntelliJ does not pick up added dependencies from the local Maven repository. We have to tell IntelliJ to reimport the pom.xml.

  1. Open the project view in IntelliJ
  2. Right click the pom.xml file and select Maven - Reimport
  3. If this works for you IntelliJ will add the dependencies to the project
  4. Check the if the dependencies you need are added in
  • File - Project Structure - Project Settings - Libraries
  • and File - Project Structure - Modules - Dependencies

Solution 2 - Maven

You don't have to reimport manually each time. You can enable auto-import as documented here. Change this in Settings -> Maven -> Import Maven projects automatically.

Solution 3 - Maven

IntelliJ IDEA 2016

Import Maven projects automatically

Approach 1

  • File > Settings... > Build, Execution, Deployment > Build Tools > Maven > Importing > check Import Maven projects automatically

Import Maven projects automatically

Approach 2

  • press Ctrl + Shift + A > type "Import Maven" > choose "Import Maven projects automatically" and press Enter > check Import Maven projects automatically
Reimport

Approach 1

  • In Project view, right click on your project folder > Maven > Reimport

Approach 2

  • View > Tools Windows > Maven Projects:

  • right click on your project > Reimport

or

  • click on the "Reimport All Maven Projects" icon:

    Reimport All Maven Projects

Solution 4 - Maven

You need to go to: Maven settings -> Auto-Reload Settings

Auto-Reload Settings

Then check "Any Changes":

enter image description here

Solution 5 - Maven

File>Settings>Build,Execution,Deployment>Maven> Check : Always update snapshot

That worked for me.

Solution 6 - Maven

Uncheck

> "Work Offline"

in Settings -> Maven ! It worked for me ! :D

Solution 7 - Maven

For some reason IntelliJ (at least in version 2019.1.2) ignores dependencies in local .m2 directory. None of above solutions worked for me. The only thing finally forced IntelliJ to discover local dependencies was:

  1. Close project
  2. Open project clicking on pom.xml (not on a project directory)
  3. Click Open as Project

List item

  1. Click Delete Existing Project and Import

enter image description here

Solution 8 - Maven

in IntelliJ 2020 in the pom.xml view one should be able to apply pom changes by following key combination: CTRG + SHIFT + O.

And as correctly commented before - IntelliJ additionally shows a balloon widget to import changes.

Solution 9 - Maven

I tried absolutely everything to get IntelliJ to pickup my pom.xml changes but it just wasn't doing it. I commented out all of the <dependencies> in pom.xml and rebuilt the project which should've shown hundreds of compile errors but didn't.

In the end, I had to delete the .idea folder to get IntelliJ to regenerate it's maven model. Once I did this, subsequent changes to pom.xml were picked up when I did a "Reload All Projects" so I suspect a bug where IntelliJ is using a cached model rather than updating it when changes are made.

Here's what I did:

  1. Close the project in IntelliJ (file -> close project)
  2. Delete the .idea folder in the root folder of the project
  3. Open the project again in IntelliJ
  4. Maven -> Reload All Projects
  5. Build -> Rebuild Project

Solution 10 - Maven

Apart from checking 'Import Maven projects automatically', make sure that settings.xml file from File > Settings > Maven > User Settings file exist, If doesn't exist then override and provide your settings.xml file path.

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
QuestionJan HView Question on Stackoverflow
Solution 1 - MavenJan HView Answer on Stackoverflow
Solution 2 - MavenDaniel KaplanView Answer on Stackoverflow
Solution 3 - MavenROMANIA_engineerView Answer on Stackoverflow
Solution 4 - MavenEyal SoolimanView Answer on Stackoverflow
Solution 5 - MavenaevinView Answer on Stackoverflow
Solution 6 - Mavennicou50View Answer on Stackoverflow
Solution 7 - Mavenk13iView Answer on Stackoverflow
Solution 8 - MavengitrustView Answer on Stackoverflow
Solution 9 - Mavenlance-javaView Answer on Stackoverflow
Solution 10 - MavenuserView Answer on Stackoverflow