IntelliJ is not recognizing Maven Dependencies

Viewed 4289

I have a Spring Project in which I am using Maven to manage my dependencies. I have some (5 to 10) packages mentioned inside the POM-File and Maven is successfully downloading them into my local repository.

But IntelliJ is not recognizing these packages. Not even the SpringBoot-Packages.

I have tried different things:

  • Delete local Maven-Repository
  • Create a new Project inside IntelliJ from existing Sources but with the same Directory as the original Project
  • Create a new Project inside IntelliJ from existing Sources but I have copied the src-Folder and the POM-File to a new Directory first

Why is IntelliJ not recognizing the Maven-Dependencies?

P.S.: The Maven-Build is successful. So Maven IS recognizing the packages inside the repository.

6 Answers

IntelliJ seems to handle an Index for all dependencies inside the project. And this Index was not correctly handled in my case by IntelliJ.

But I found out that I can manually clear this cache/index by using following function:

File > Invalidate Caches / Restart...

In case that the problem still exists after File > Invalidate Caches / Restart... (as suggested by @Snickbrack), reload the maven projects by Maven > Reload all maven projects.

Just open maven pom.xml as project instead of creating new project from sources

Please run the command mvn idea:idea it will work.

Right click on pom.xml Maven -> Reload project

Please check the maven home path by following the steps below:

  1. Select the project in Project window >> File >> settings>> Build,Execution,Deployment >> Maven
  2. Check the 'Maven home path' as per Maven installation location. It will download all the dependencies.
Related