Intellij not resolving maven dependencies

Answered

I am using intellij to build my maven project. the project build successfully and run the problem is that intellij is not resolving my dependencies.I tried to restart but the problem is not being resolved. I also tried to clean the logs but no luck. Please assist

54 comments
Comment actions Permalink

Here is what worked to me >

1- Right Click the project > Maven > Download Sources 

2- Right Click the project > Maven > Reimport 

 

I think #2 is what made it, so probably no need to #1. Anyway, I do not know why I have to reimport the project to make it work. IDE should be smart enough to pickup the new lib once it's updates in the pom.xml

3
Comment actions Permalink

IDE displays a notification to reimport the project after you make a change in pom.xml, you just click on it. Another option is to enable the auto import option:

 

It will be changed in 2020.1 release, please see https://blog.jetbrains.com/idea/2020/01/intellij-idea-2020-1-eap/#maven_and_gradle_importing_updates .

 

0
Comment actions Permalink

I may have missed this, as I pulled the pom changes from git then opened the IDE. I will watch for it next time as I am new to the IDE and trying to get used to it. 

0
Comment actions Permalink

I faced with the same issue today... again =( Usually I remove .idea and %userdir%/.IntellijIdeaX folder to solve such things, but this time I was too lazy to restore all cfgs and found one more solution:

- go to %projectDir%\.idea folder

- delete compiler.xml file

- check misc.xml file, if <option name=ignoredFiles"> and its <set> somehow contains the module that Idea is unable to resolve - just remove it from there

- re-import maven project

I've wasted so many time for this issue for a lot of times, hope it will help you =)

2
Comment actions Permalink

This is also happening to me with latest EAP build #IU-201.6073.9.

Do a maven install on project a to install snapshot version locally. Attempt to use that Snapshot in project B and it doesn't pick it up.

Maven Reimport All did nothing. Going to the specific project, right clicking, maven->reimport actually worked. Something appears to be broken in reimport all.

0
Comment actions Permalink

Ben Madore please submit a ticket to support with the logs and more details: Help | Compress Logs and Show in ...

You can attach the files to the report: https://intellij-support.jetbrains.com/hc/requests/new .

0
Comment actions Permalink

I had this same issue and found an interesting problem/solution. It turns out that during the rename of my project I somehow ended up with multiple modules pointed at the same source!

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/module1.iml" filepath="$PROJECT_DIR$/module1.iml" />
<module fileurl="file://$PROJECT_DIR$/module2.iml" filepath="$PROJECT_DIR$/modul2.iml" />
</modules>
</component>
</project>

I unloaded the module which no longer represented the project and it appears to be working.

Deleted both modules and re-imported the project as a maven project again. Seems to have worked. Is there a better mechanism to clear out erroneous modules?

 

 

 

 

0
Comment actions Permalink

Hi guys,

please try mvn -U idea:idea 

It helped me and everything is working fine right now. This command is responsible for downloading project plugins for Intellij. I hope it will help you as well.

1
Comment actions Permalink

I have same problem. How can resolve this issue? İ want to add bcrypt (password hashing) with dependency but no result. Intellij version is 2020.1 ultimate

0
Comment actions Permalink

Elxan310 please share a sample project to reproduce the issue.

0
Comment actions Permalink

Facing the same issue. All the dependencies are downloaded in .m2/repository as the build passes but some of the imports are not resolved.

0
Comment actions Permalink

Please see if the workaround from https://youtrack.jetbrains.com/issue/IDEA-239150#focus=streamItem-27-4117814.0-0 helps.

There is a known issue in 2020.1 and 2020.1.1 versions: https://youtrack.jetbrains.com/issue/IDEA-237320 .

1
Comment actions Permalink

After lots of wasted time, I installed 2020.1.3 which seemed to work now.

0
Comment actions Permalink

For me, the problem is different java versions for project and maven importing settings. 

Go to Preferences -> Build, Execution, Deployment -> Maven -> Importing -> JDK for importer (at the bottom) and set to Use Project JDK (in most cases this should be a case)

 

I don't know how this was changed (maybe I downloaded Java 11) but Intellij, please group some Java versions at the same place if possible

3
Comment actions Permalink

Sometimes, in a multi module maven project with SNAPSHOT dependencies, I have to explicitly go to the project classpath and delete the old/duplicate maven dependencies in the classpath as a temporary fix. This besides if these don't work: Reload, Delete .iml, .idea  folders or mvn -U idea:idea .

0
Comment actions Permalink

Hello, I am facing quite the same issue. I have one maven project that contains my "domain" classes.

First I run mvn install install and I can see that jar is installed to /Users/user/.m2/repository

Then I change pom.xml of second project to point out to installed dependency. Maven>Reload project works as expected and everything is fine so far. Then when I go again to Editor and try to use the class from first project, I can see the class in recommendation but dependency seems not resolved:

Recommendation works with full classpath:

 

subpackage is not resolved. com.hedwell is resolved only because this project has also com.hedwell as a root level package.

 

----

Edit:

I was wrong, since I tried to import spring-boot project which is not supported by default (not because of intellij but spring-boot) . Adding plugin solves the issue, it creates two jars with mvn package, one that is spring-boot-exec and one that can be used in other projects as dependency: 

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>

 

0
Comment actions Permalink

Mihailo Stupar Please see if the workaround from https://youtrack.jetbrains.com/issue/IDEA-239150#focus=streamItem-27-4117814.0-0 helps. If the issue remains try to do:

  • File \ Invalidate caches and restart...

  • Close your project window (and IntelliJ) and remove all *.iml files and the .idea folder.

  • Delete/Rename .m2 maven folder.

  • Run mvn clean install from the command line.

  • Re-import the project into IntelliJ from Existing sources.

 

1
Comment actions Permalink

I have sometimes the same issue with sbt. I found that deleting the ./idea/libraries  xml files and a refresh on the project fixes the problem. Might also work on maven.

0
Comment actions Permalink

Hello,

I am facing an issue when opening a project my dependencies are not loading i tried everyway but it doesn't get load.

Also maven tool is not showing on the right side.

Maven option is not appearing when right click on pom.xml file

Anyone can please assist why i am facing this?

Here is the screenshot for reference.

Intellij 2021

0
Comment actions Permalink

@Egor Klepikov Thanks to you :)
I follow your steps & it works for me (Y)

0
Comment actions Permalink

I have had this type of issue quite a few times now (current version - 2021.1.1 Ultimate, IntelliJ IDEA 2021.1.1 (Ultimate Edition, Build #IU-211.7142.45, built on April 30, 2021)
We have nested poms and sometimes Intellij doesn't recognise that, so you can see all the source just none of the external libs, and you can't click off to the external libs (you can even get intellij to build the code when it should fail), so we have soemthing like:

and to get it to be recognised, Ihave to right click the pom and add as a Maven Project

 

 

 

0
Comment actions Permalink

i got the same problem but to fix that i just did file-> invalidate caches. hope this can help someone

0
Comment actions Permalink

Had the same issue, I had to right-click on the pom file, go to Maven then Reload project.

And the issue was resolved.

0

Please sign in to leave a comment.