'mvn dependency:tree -Dverbose hangs and never finishes

I have a version conflict in transitive dependencies in my project, and I'm trying to use mvn dependency:tree -Dverbose to find the version conflict. However, whenever I run mvn dependency:tree -Dverbose, it just hangs and never finishes. I tried using the debug mode (mvn --debug dependency:tree -Dverbose) to find out what's going on, and it seems that it's connecting to hundreds and hundreds of repositories, that I have defined nowhere anywhere in my project, writing tracking file, using connector, using transporter, etc...... see the pastebin here for a small snippet of the things that it just does for hours and hours: https://pastebin.com/raw/L3z4u5Hj

This doesn't happen when I don't include the -Dverbose flag: mvn dependency:tree on it's own is super snappy and completes in seconds.

Also, this doesn't happen for any other repositories or codebases that I have: only a specific one. But obviously I don't know what's different about this codebase than the other ones, only that the dependencies are different (assuming that some dependency is the cause of the problem.)

It seems that people on the official maven mailing list ran into this issue too, but it seems they were never able to solve it either: https://www.mail-archive.com/[email protected]/msg143124.html

Any help would be appreciated. If I can't figure this out, I'll have to resort to removing dependencies one by one until I find the one that is causing the problem, and that will take a very long time because this is a very large codebase.

maven version:

Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.10, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-54-generic", arch: "amd64", family: "unix"


Solution 1:[1]

this issue can be recreated with a demo project created with https://start.spring.io/ and selecting spring boot version 2.6.0 or higher without any other dependencies. It does not happen with version 2.5.9

Solution 2:[2]

I had the same problem with my Spring boot project. As pointed out before, the maven-dependency-plugin:3.2.0 seems to be the problem.

The issue was fixed in version 3.3.0 https://issues.apache.org/jira/browse/MDEP-761

My fix was to add the new version as plugin to the pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.3.0</version>
</plugin>

Solution 3:[3]

This is happening when we use maven-dependency-plugin:3.2.0 version. I tested with version 3.1.2 and the dependency tree is built quickly as usual. BTW.. spring-boot-dependencies >= 2.6.0 are using maven-dependency-plugin:3.2.0 so beware.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 amoor
Solution 2
Solution 3 Devendra Narayan Jemili