IntelliJ not resolving Maven dependencies

Answered

Hi everybody !

I'm having a problem with IntelliJ. It's not resolving Maven dependencies (the External Libraries remains empty and all classes from dependencies are red in the editor). When using clean install with the Maven plugin or via the command line it works though.

 

I already tried to :

  • Reimport the project with Maven
  • Invalidate the cache and restart IntelliJ
  • Delete the .idea folder and the .iml files
  • Delete my maven repository folder
  • Update the maven repositories indices in IntelliJ
  • Delete the maven folder in IntelliJ configuration folder

As none of this worked I'm beginning to think I won't find a solution.

 

Here is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>libraries-apache-commons</artifactId>
<name>libraries-apache-commons</name>

<parent>
<artifactId>parent-modules</artifactId>
<groupId>com.baeldung</groupId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commons-beanutils.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${commons-text.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>commons-chain</groupId>
<artifactId>commons-chain</artifactId>
<version>${commons-chain.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>${commons-csv.version}</version>
</dependency>
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>${commons.dbutils.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>${common-math3.version}</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>${commons-net.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>org.knowm.xchart</groupId>
<artifactId>xchart</artifactId>
<version>${xchart-version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commons.collections.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
<version>${org.hamcrest.java-hamcrest.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<properties>
<commons-lang.version>3.6</commons-lang.version>
<commons-text.version>1.1</commons-text.version>
<commons-beanutils.version>1.9.3</commons-beanutils.version>
<commons-chain.version>1.2</commons-chain.version>
<commons-csv.version>1.4</commons-csv.version>
<assertj.version>3.6.2</assertj.version>
<commons.io.version>2.5</commons.io.version>
<commons.dbutils.version>1.6</commons.dbutils.version>
<commons.collections.version>4.1</commons.collections.version>
<org.hamcrest.java-hamcrest.version>2.0.0.0</org.hamcrest.java-hamcrest.version>
<commons-codec-version>1.10.L001</commons-codec-version>
<xchart-version>3.5.2</xchart-version>
<commons-net.version>3.6</commons-net.version>
<common-math3.version>3.6.1</common-math3.version>
</properties>

</project>

 

I also attach a printscreen of my IntelliJ:

 

I also uploaded the IntelliJ log folder using the webform. The filename is log.zip.

 

I'm using version 2019.1.2 of IntelliJ.

 

Thanks a lot,

François

2
32 comments
    <parent>
<artifactId>parent-modules</artifactId>
<groupId>com.baeldung</groupId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Make sure you have also imported the parent module into current IDE project (you can import it from Maven projects tool window using + icon).

0

Hi,

Thanks for your rapid answer. Sorry I couldn't catch up until today.

I just imported the parent module, but nothing changed, unfortunately. As a matter of fact, I did also try to import the whole parent project with all the submodules and I had the same problem.

0

>I did also try to import the whole parent project with all the submodules and I had the same problem.

Indeed if any of the current module's properties are defined in any of the parent maven modules - all those modules must be imported and be visible in Maven tool window in order for IDE to resolve the dependencies. Please make sure you have imported all the parent modules and importing process completed successfully: try also to re-create project by importing it from the main parent pom.xml: File | New | Project from Existing Sources and select main pom.xml file to import from.

Please also make sure that the project can be built by Maven from command line.

If issue remains attach idea.log file after refreshing project in Maven tool window.

For uploading you can use ftp://ftp.intellij.net/.uploads / https://uploads.services.jetbrains.com or any file sharing service.

1

Hi,

Thanks for following up.

Unfortunately, I already tried all that (importing parent module, reimporting the project) and nothing seems to work :-/.

I uploaded my idea.log file after refreshing the project with Maven.

Hope it'll be useful.

0

Looks like https://youtrack.jetbrains.com/issue/IDEA-200272

Please try 2019.2 EAP from https://www.jetbrains.com/idea/nextversion/

You could also try if it works to use lower extension version or disable it (comment out in pom): https://github.com/vackosar/gitflow-incremental-builder#disable-in-ide

0

Hi!

Installing version 2019.2 EAP did the trick :-). Thank you very much for helping me out!

Kind regards!

François

0

HI, 

I am facing the same issue. I am using the Version 2019.3. My POM.XML is as below. Please help me with the correct Dependencies. The Maven repositories are not Imported. 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>KarateDemo</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>

<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>0.9.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>0.9.4</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
0

Kanth96 I see no problem with your pom.xml(https://i.imgur.com/0wRiF2t.png). Have you tried that: 

  • Reimport the project with Maven
  • Invalidate the cache and restart IntelliJ
  • Delete the .idea folder and the .iml files
  • Delete Maven repository folder

 

0

The problem for me was the setting of the local repository (settings>Build, Execution, Deployment>Build Tools>Maven>Local repository). My settings.xml was using a different repository as the one configured in Intellij.

0
Avatar
Permanently deleted user

I faced a similar challenge. For me, it was because of the spring-boot-maven-plugin. As I have noticed mostly from multi-module projects (it seems to affect even single module projects sometimes), if you do not put the <plugin> in a <pluginManagement> tag in the problematic dependency module or the parent module, the resulting jar may be empty. I'm not sure how or why this happens but the workaround is to simply wrap the <plugin> with a <pluginManagement> tag, and re-install (mvn clean install). this should resolve the problem. You may need to re-import the dependencies if auto-import/auto-update is not enabled

 

<build>
<pluginManagement> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.3.0.RELEASE</version>
</plugin> </plugins>
</pluginManagement>
</build>
6
Avatar
Permanently deleted user

@..., where did this auto-import/auto-update toggle go to? I can no longer find it in IntelliJ settings.

0

I'm having similar problems, I was using Maven and I migrated to Gradle to see if it improved, nothing, same errors, IntelliJ Ultimate doesn't solve the dependencies and several times a day I have to delete the .idea folder, delete the .iml and create a new project from the sources.
In the 2019 version it worked very well, I'm sorry, but it seems to me that the 2020 versions have several bugs.

1

Please report at https://youtrack.jetbrains.com/newIssue?project=IDEA with more details and the logs (Help | Collect Logs and Diagnostic Data).

0
Avatar
Permanently deleted user

I had this exact problem and found that all the above steps did not work. However when i deleted the .idea folder and .iml file i was able to reimport and all dependencies were found again. Seems to me that the libraries folder in .idea just never updated.
Hope this helps someone

0

I have the same problem with 2021.1.1

The only way to make it work is to perform a maven build outside of IntelliJ and then it works. But that is really frustrating because a few minutes later the problem can return for no apparent reason.

 

0

David Nouls If none of the above steps help please raise a new issue at https://youtrack.jetbrains.com/issues/IDEA with a screenshot and logs attached. (Help | Collect Logs and Diagnostic Data)

Also, try using the 2021.1.2 IDEA from https://www.jetbrains.com/idea/download .

0

@... adding <pluginManagement> tag saved my day too.Thanks

I couldn't be angry more than this. Why? That ruin my 2 days. So stupid error.

 

 

 

1

Faced the same problem in 2021.2.3

Tawanda's comment about pluginManagement needing to be in the POM fixed it for me

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003887520/comments/360001751799

 

1

I am facing the same problem since a couple of days. I noticed, that a branch of a colleague does not work, because there was a new dependency added and this was not added to the project on intelliJ. I can compile everything on command line, also the dependencies are downloaded into my local m2 repo, but they never appear in my project thus making intelliJ unable to use.

Any advices? I've also updated from 2021.2.2 to 2021.2.3 yesterday, but this has not helped. I cannot work at the moment in intelliJ's current state O.o

0

Hello!

Have you tried to run "Reload" from maven tool window? If it doesn't help please report issue on YouTrack (https://youtrack.jetbrains.com/issues/IDEA) attaching logs folder zipped (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files) after restarting IDE and running "Reload"

0

Yes, I tried to run reload from maven tool window, no change at all.
I noticed, that when I either comment the aspectj maven plugin in the pom OR disable the aspectJ plugin (from jetbrains) in intelliJ the update works again.

1

Is it possible to provide sample project example demonstrating the issue?

0

For me the problem was a conflicting JAXB runtime which was introduced by ehcache. This broke all idea dependency resolving, so I had to exclude like this: 

<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.10.0</version>
<exclusions>
<exclusion>
<artifactId>jaxb-runtime</artifactId>
<groupId>org.glassfish.jaxb</groupId>
</exclusion>
</exclusions>
</dependency>

0

There was this issue for me and I clicked the branch and did an Update action. Then all IDE errors in import went away. 

0

So any update on this??? So many years and still it is not fixed. 

0

Hello Giorgos,

Please report issue on YouTrack (https://youtrack.jetbrains.com/issues/IDEA) attaching idea.log ("Help | Show Log in…") after running “Reload” from Maven tool window. If it's possible , please attach sample project demonstrating the issue.

0

Hello Yaroslav, 

This issue is already tracked by multiple other open ones. Like

https://youtrack.jetbrains.com/issue/IDEA-347497/Erro-Reload-Maven-Artifactory

https://youtrack.jetbrains.com/issue/IDEA-352651/Why-so-many-inexplicable-errors-in-the-2024-version

etc

In previous versions we could invalidate caches and reload maven project and it would work fiding the new updated dependencies. This has now 2024.1 stopped working. Only way seems to be downgrading to previous versions of the IDE

0

Thanks! I'll ask developers to check them as soon as possible.

0

Thank you for your support, for now switching back to 2023.3.6 version fixes the issue (only by invalidating caches though)

0

Please sign in to leave a comment.