How can I make IntelliJ IDEA update my dependencie

2019-01-07 20:24发布

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?

5条回答
太酷不给撩
2楼-- · 2019-01-07 21:09

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
查看更多
虎瘦雄心在
3楼-- · 2019-01-07 21:13

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

查看更多
干净又极端
4楼-- · 2019-01-07 21:18

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.

查看更多
来,给爷笑一个
5楼-- · 2019-01-07 21:23

Uncheck

"Work Offline"

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

查看更多
神经病院院长
6楼-- · 2019-01-07 21:25

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.

查看更多
登录 后发表回答