Why Intellij do not find any Maven dependencies in pom.xml?
Asked Answered
P

5

12

I just downloaded Intellij on a laptop and I imported a Maven project and the problem is that Intellij do not found any dependency in pom.xml. For example if I try to import hibernate-core or any other dependency I get the error: Dependency org.hibernate-core... not found. What should I do? Any feedback will be appreciated.

Pheidippides answered 16/8, 2019 at 7:26 Comment(5)
Are you able to run the command like mvn clean package from command line ?Cucumber
Run mvn install command. It will download all the dependencies.Krouse
Sometimes intellij idea do not refresh maven dependency on startup. To do so on the right side of idea there is docked panel with Maven. Just open it and click refresh. Should reload project and you should see difference.Borzoi
@Cucumber Yes I'm able to run the command from command linePheidippides
@Pawel If I try tu run refresh I get an error: Cannot resolve plugin org.apache.maven.plugins:maven-release-plugin:2.5.3 … 11:02 AM Error running 'refresh': Cannot run program "refresh" (in directory "D:\Projects\my-project"): CreateProcess error=2, The system cannot find the file specifiedPheidippides
C
20

In case of Intellij Idea, make right click on pom.xml, select maven and then click to reimport. Find below the screenshot.

enter image description here

Cucumber answered 16/8, 2019 at 8:7 Comment(3)
Looks like this option was replaced with Reload project, which solved the problem for me. Why we have to do this by default is beyond me -- extremely, extremely frustrating.Bowne
Doing the refresh for maven and gradle is unfortunately a way of life in Intellij. 2022 and this still isn't ironed out well.Scribble
Doesn't work with 2022.2.3 IntelliJ is really buggy, bad quality IDE compared to VS Code, Eclipse etcZavala
S
13

I solved this issue by running "mvn idea:idea" command. It resolved all module dependencies and also add it to classpath in intellij.

Shetrit answered 29/12, 2020 at 10:9 Comment(5)
can you please explain what that command does?Boyd
Doesn't work with 2022.2.3 IntelliJ, running above command from project directory, it did download many libraries but still I couldn't get rid of basic errors in import. I doubt if project is referring to these downloads or not ? IntelliJ is really pain in doing these basic operationsZavala
I can confirm on June 2023, it works. Sometimes maven --> reload works, sometimes this is needed.Gleet
It works like a charm on idea 2021.2.3 (community edition) - probably it is needed when adding dependency on third party libraries not commonMetropolis
Right click pom.xml, Maven --> Reload. Did the trick. Thanks @nayakasu!Finch
D
4

It may also be worth checking which Maven your IDE is using. You can check it in settings:

enter image description here

We used to have issues with Maven bundled with IntelliJ.

Dimpledimwit answered 16/8, 2019 at 8:32 Comment(2)
I helped. I had set up location of my maven directory. When I switched to Bundled (maven 3) option then it updated the librariesBrandi
Doesn't work with 2022.2.3 IntelliJ, there is no Maven option seen under Build Tools. Not sure why does IntelliJ keep changing UI each release ? Most bad quality IDEZavala
E
1

You could also go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Repositories and check that the local maven repository is set.

Same for File -> Settings -> Build, Execution, Deployment -> Remote Jar Repositories where the remote maven repository should be set (something like https://repo1.maven.org/maven2)

Evangelia answered 16/8, 2019 at 7:41 Comment(1)
Not applicable for 2022.2.3 IntelliJZavala
C
0

After "Maven" > "Reload project" an additional "Build" > "Rebuild project" (in IDEA window menu) was necessary to eliminate all "dependency ... not found" error messages in my case.

Canicular answered 2/7, 2022 at 6:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.