Not all Maven dependencies appear in "External libraries"

Answered

Hello folks.

This is a problem I have been experiencing for a while. Each time a new version of IntelliJ is release I think "hopefully this will fix it" but they never do :p

So, I have something like this:

http://i.imgur.com/ydnig.png

This happens with many libraries. All those libraries are in the main repo and if I run mvn clean install from the command line it works fine. I mean, this is an IntelliJ problem, not something wrong with Maven and its dependencies.

Is there a way to make it work? Something like clearing some intellij-maven cache or forcing the import (doing Maven -> Reimport does not work). This is driving me nuts :(

12 comments
Comment actions Permalink

It's most likely an incomplete or corrupted index.

Assuming you have done a reimport of the project via the import button on the maven tool window, you can try the following:

1st option:
1) go to File > settings > Maven > repositories
2) In the  top pane, where it says "Indexed Maven Repositories", select your local repository and click the update button. This will update the indexing of your local repo. Wait for it to finish.
3) reimport the maven project via the import button on the maven tool window.

2nd option:
If that does not work, try invalidating your caches via File > Invalidate caches and then restart IDEA. I know that that invalidates project caches, but I'm not sure about the Maven caches. But give it a try.

3rd option:
If that does not work, here's a more drastic approach that will resolve any potential corruption.
1) Close idea
2) Go to IDEA's configuration directory (the .IntelliJIdea directory, usually  in your home directory). Inside it is the "system" directory.  In the system directory is a "maven" directory. Move or delete the "maven" directory. It has all the indexes and caches in it.
3) Restart IDEA
4) Wait for IDEA to reindex the maven repository (watch it into status bar or open the background tasks to watch it.)
5) when it's done reindexing, reimport the maven project by Clicking the import button in the maven tool window.

2
Comment actions Permalink

This worked for me:

File > settings > Maven > Automatically Import Maven Projects

File > Invalidate Caches and Restart 

Then just let Intellij import as maven project

0
Comment actions Permalink

I also had this problem, I tried everything mentioned here, but they did not work!! the issue was that in maven projects section, my maven projects were ignored for some reason!!So I just right clicked on each project and clicked unignore project!!after that I did everything mentioned here and it worked

4
Comment actions Permalink

@Jmeen011 Your answer worked for me, I simply had to do invalidate caches and restart for intelliJ to reinsert all my dependencies. Thanks 

0
Comment actions Permalink

@Elham's answer was my solution. Check the Maven tool window to see if the module is grayed out. If it is, you're ignoring it. Right click and choose Unignore Projects. 

2
Comment actions Permalink

I closed Intellij IDE and deleted .idea folder in the project root and restarted the IDE. It worked! 

0
Comment actions Permalink

I had a similar issues, the above did not work for me but what did work ...

We have several nested layers of poms, the top level pom was recognised by Intellij but the lower level poms in the subdirectory were not, so I right clicked the lower level pom.xml and chose 'Add as Maven Project'

0
Comment actions Permalink

I am also having the issue, none of solution above helped me.

The only way I could refresh the dependencies was restarting the idea, since I can not develop that way, I found a very ugly workaround which does not force me to restart Idea, every time I want to reload project I  go to maven settings and change the maven which the idea uses (I have the maven that came with the IDEA,  and a manual installed maven, so I simply replace it each time I want to reload the module)

0
Comment actions Permalink

Eran Friedland

Is it the same for all of your Maven projects or is it just one that is affected?

Try deleting the .idea folder (backup first) from the project, and re-importing your project to the IDE via File | New | Project from Existing Sources > pom.xml.

You can also try the 2020.3 EAP version of IDEA to benefit from fixes to potentially related issues.

0
Comment actions Permalink

Arina Efremova

I have tried to delete the directory, that did not help me.

This is an issue only for one module.

I am not the only one with that issue for the specific module, that leads me to conclude that I might have an issue with the module, on the other hand, going to maven settings, change the current maven every time I modify the "pom.xml", refresh the dependencies.

 

0
Comment actions Permalink

@Eran Friedland please report the issue at https://youtrack.jetbrains.com/issues/IDEA  with idea.log (Help | Show Log in ... action) file right after problem happens and description of the steps after which the problem happens and the description of the problem (expected/actual result you see). Thank you.

Please also make sure to try the version from https://www.jetbrains.com/idea/nextversion/

0
Comment actions Permalink

In my case, I've got this problem when I try to duplicate a module in my project and rename it. Maybe something broken while doing this.

Finally I resolved this problem by doing as following

1. Manually add the required library to project: File > Project Structure... > Libraries > press the "+" button (see the picture below)

2. Add the library to the module dependencies. 

0

Please sign in to leave a comment.