I have a proprietary dependency that I use in my project that I can not refuse. It was built in one big fat jar with all dependent packages collected inside. By all I mean even common ones like slf4j-api, apache-commons, javax packages, etc.
Using it together with my own list of declared dependecies is risky because there's always a race in classloader on which class will be loaded first - mine or outdated class inside fat jar.
I was wondering is there a way around this problem? How to treat such fat jars? I'm using maven for dependency management.
In Maven, the order in which you define dependencies in your POM is significant. If you list them in the correct order, they should be added to the jar in that order, and whichever class is higher in the file, that's the one that will get loaded first.
If you will compose your runtime classpath out of multiple jars, then again, it's a matter of putting the jars in the right order.
If you know that some functionalities of the fat jar will work when you exclude some fo their dependencies or you want to include them yourself, you can try this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With