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.

5
  • 3
    Are you able to run the command like mvn clean package from command line ? Commented Aug 16, 2019 at 7:27
  • 2
    Run mvn install command. It will download all the dependencies. Commented Aug 16, 2019 at 7:31
  • 3
    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. Commented Aug 16, 2019 at 8:01
  • @Sambit Yes I'm able to run the command from command line Commented Aug 16, 2019 at 8:01
  • 1
    @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 specified Commented Aug 16, 2019 at 8:07

5 Answers 5

21

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

Sign up to request clarification or add additional context in comments.

3 Comments

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.
Doing the refresh for maven and gradle is unfortunately a way of life in Intellij. 2022 and this still isn't ironed out well.
Doesn't work with 2022.2.3 IntelliJ is really buggy, bad quality IDE compared to VS Code, Eclipse etc
14

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

5 Comments

can you please explain what that command does?
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 operations
I can confirm on June 2023, it works. Sometimes maven --> reload works, sometimes this is needed.
It works like a charm on idea 2021.2.3 (community edition) - probably it is needed when adding dependency on third party libraries not common
Right click pom.xml, Maven --> Reload. Did the trick. Thanks @nayakasu!
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.

2 Comments

I helped. I had set up location of my maven directory. When I switched to Bundled (maven 3) option then it updated the libraries
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 IDE
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)

1 Comment

Not applicable for 2022.2.3 IntelliJ
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.