Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 212
Jan H Avatar asked Jun 07 '13 20:06

Jan H


People also ask

How do I force an update dependencies in IntelliJ?

Press Ctrl + Shift + A to find actions, and input "reload", you will find the "Reload All Maven Projects". On a Mac, use ⌘ + ⇧ + A instead.


3 Answers

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
like image 184
Jan H Avatar answered Oct 27 '22 01:10

Jan H


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.

like image 33
Daniel Kaplan Avatar answered Oct 26 '22 23:10

Daniel Kaplan


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

like image 21
ROMANIA_engineer Avatar answered Oct 27 '22 01:10

ROMANIA_engineer