Dealing With Duplicate Fully Qualified Names

て烟熏妆下的殇ゞ 提交于 2019-12-02 05:56:44

问题


Like the title says, is there a way to deal with this? I have imported two separate third party libraries and they have a fully qualified class name conflict.

Right now both libraries are being imported in jar form, and it appears that in some environments (command line invocation, Eclipse) the correct class is found and in others (Maven) the wrong class is found and I get a missing method exception. If no solution can be found, I can fall back to re-factoring one of these libraries and rebuilding the jar, but I would rather not have to repeat that work every time the library has an update.

Edit: If anyone sees this later and is confused, I accepted Dave Newton's answer because it would be the correct way to do this if you were diligent enough to catch this problem before writing all of your code. Fixing the imports automagically after writing all the code appears to be impossible, as I suspected.


回答1:


You either shade, bust them apart and remove the dupes, or...

When you have multiple implementations you are at the mercy of your classloader(s) unless you take active steps to mitigate the dupes.

Further discussion at this SO question.



来源:https://stackoverflow.com/questions/12823048/dealing-with-duplicate-fully-qualified-names

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!