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

I have a similar issue with Spring annotation, after deleted the cache folder in my user home `/Library/Caches/IntelliJIdea2019.3/` was solved. 

0
Comment actions Permalink

I keep running into this issue.

Maven is cool with the pom dependencies but Intellij is not.

mvn can compile and test but intellij won't build the project.

Tonight it won't recognize that: import org.openqa.selenium.remote.DesiredCapabilities;

is legit and in dependency:

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
0
Comment actions Permalink

Same problem, just updated a dependency to pick a new function and mvn build works great, and intellij still pointing to the old version. I confirmed both versions exist on my desk after mvn install, so deleted the old version and it's just decided to complain the whole package does not exist. I did everything recommended above, and intellij still looking for the old deleted version. 

0
Comment actions Permalink

Does it help if you delete .idea directory and reimport the project from pom.xml?

(make sure to create a backup of this directory and then copy back the code styles, run configurations and other configuration files that are not related to the module and project structure, don't copy modules.xml back).

0
Comment actions Permalink

I do not want to do this. I got a lot of setup for this project that I do not want to re-do. tbh, I am new to intellij because eclipse is getting to be very slow, but if I have to setup this project, I will have to do it in eclipse. Because I can not set it up everytime there is a lib change, which is very common. 

0
Comment actions Permalink

Normally all the changes to the dependencies should be picked up automatically just after the refresh of the project. If it doesn't work for you, please submit a ticket to support ( https://intellij-support.jetbrains.com/hc/requests/new ), attach the logs (Help | Compress Logs and Show in ...) and a small sample project to reproduce the issue.

0
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

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

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

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

0
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

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
Comment actions Permalink

Can you resolve the dependencies using maven from the command line?

If you are behind a proxy or go via a corporate maven repo you will have to edit your maven settings file (~/.m2/settings.xml)

-1

Please sign in to leave a comment.