Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a library reference in Intellij Idea

I have a complex project with a lot of Maven libraries. From time to time I am facing the problem of a library version conflict. I can open the class which is conflicting and see all libraries a class is packed in. But unfortunately I don't find an easy way to check where these libraries are referenced in the Maven dependencies. Do you have an idea how to find a library in the Maven tree?

like image 392
Thomas Avatar asked Feb 20 '18 07:02

Thomas


2 Answers

You need Maven Helper plugin

https://plugins.jetbrains.com/plugin/7179-maven-helper

It has a dependencies viewer and lets you resolve conflicts right there. Open your pom file after installing the plugin and you will see another tab at the bottom of the editor window.

Right click on any dependency to bring up the context menu and you will see an option to exclude it. It will add exclude to your pom file. That obviously won't work for uberjars.

enter image description here

like image 64
Devstr Avatar answered Sep 22 '22 00:09

Devstr


Going more low-tech, you can let maven tell you the answer with the command

mvn dependency:tree -Dincludes=groupId:artifactId

You can also invoke this command simply from an Intellij terminal window.

mvn dependency:tree will print the entire tree, the includes addition will let you filter on a specific artifact making it easier to search (although I've been known to just copy the entire tree into a scratch file and just do searches on it there).

If you don't know the groupId or the artifactId is already unique enough, you can filter like this:

mvn dependency:tree -Dincludes=*:artifactId
like image 20
Gimby Avatar answered Sep 18 '22 00:09

Gimby