9

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.

4
  • Are you using any proxy? Are these dependencies related to any "corporate repository"? IntelliJ by default uses its default embedded Maven, its settings could differ to your "maven prompt". Could you show an error screen or something about the IntellJ error please? Commented Jan 11, 2021 at 11:09
  • Yes, I am using a proxy which is set inside the Settings.xml. The dependencies are placed inside a corporate repository or lets say a local nexus. IntelliJ doesnt prompt an error for downloading the dependencies but shows errors for the used classes not to be found. Commented Jan 11, 2021 at 11:20
  • @sigur this is an example error here java: package org.aspectj.lang does not exist Commented Jan 11, 2021 at 11:21
  • If I am in your case I should go for these: which settings.xml and local repository is using IntelliJ Maven (Go to Settings and look for Tools > Maven) and then execute an Invalidate Caches and Restart of IntelliJ Commented Jan 11, 2021 at 13:14

8 Answers 8

11

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...

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

1 Comment

so annoying that Intellij is not able to fix it
9

I had the same problem. Right click on pom.xml -> maven-> Reload Project, Resolved my problem.

2 Comments

This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
Invalidating the cache didn't work, but your solution did!
6

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

Comments

3

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.

Comments

0

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

5 Comments

How can I open the project with only a POM-File? Why are you not showing the process here?
File -> Open -> select pom.xml -> confirm "open as project"
I did this but it shows the same errors as the packages are not recognized...
Environment variables like M2_HOME are set?
Variables JAVA_HOME and MAVEN_HOME are set, yes.
0

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.

Comments

0

Sometimes this works

1 Comment

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
-3

Right click on pom.xml Maven -> Reload project

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.