: a tool help finding jar files contents classes with same name

Some days earlier, when I use hibernate-validator as a Java Bean validator, something went wrong when the validator runs. It throws an exception for there isn’t a field named Level.TRACE in log4j. I Googled for solutions, I try to update the version of dependency, everything looked fine, but it just not work.

However, I was very sure that there was a confliction of classes, but it takes time to figure out where the confliction is. Finally, about an hour later, I find the conflict classes and then exclude the dependency I don’t need, then the problem was solved.

On the weekend, I wonder how many dependent classes of my application may conflict, I started to write this script in Python. You can get my source code from here if you like.

It is easy to use, if and only if you know how to install some extra Python module and run a Python script.

It needs a module name tabulate to print the result in a markdown format table. Runing the following command to install the module.

pip install tabulate

You can just run the program with -h to get the usage information.

usage: [-h] [-m MAVEN_REPO] path

find conflict librarys for java web application

positional arguments:

path path to $appName/WEB-INF/lib

optional arguments:

-h, --help show this help message and exit
-m MAVEN_REPO, --maven-repo MAVEN_REPO
path to local maven repository

In addition, if the -m argument is given, then the output of conflict jar is like “groupId:artifactId:version”.

Hope this tool helps!

Like what you read? Give 潘家邦 a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.