5

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.

elvis
  • 738
  • 6
  • 23
  • 41
  • 3
    Are you able to run the command like mvn clean package from command line ? – Sambit Aug 16 '19 at 07:27
  • 2
    Run `mvn install` command. It will download all the dependencies. – Khalid Shah Aug 16 '19 at 07:31
  • 2
    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. – Paweł Głowacz Aug 16 '19 at 08:01
  • @Sambit Yes I'm able to run the command from command line – elvis Aug 16 '19 at 08: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 – elvis Aug 16 '19 at 08:07

4 Answers4

14

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

Sambit
  • 7,063
  • 5
  • 29
  • 58
  • 8
    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. – Hatefiend Feb 13 '21 at 12:19
5

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

rhizo888
  • 96
  • 1
  • 2
2

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.

mate00
  • 2,379
  • 5
  • 24
  • 33
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)

robingood
  • 319
  • 2
  • 10