简体   繁体   English

maven-shade-plugin:maven 如何在不同的 jar 中遮蔽相同的类?

[英]maven-shade-plugin: how maven shade same class in different jar?

If my project depends on two jars, A and B, which both in turns depends on class foo.bar.FooBar.如果我的项目依赖于两个 jar,A 和 B,这两个 jar 又依赖于类 foo.bar.FooBar。 But they includes different versions of FooBar in their jars, and only work with that specific version, eg A depends on FooBar v1, B depends on FooBar v3.但是他们在他们的 jars 中包含了不同版本的 FooBar,并且只适用于那个特定版本,例如 A 依赖于 FooBar v1,B 依赖于 FooBar v3。

Then when the shade plugin merges A and B into the final fat jar, how maven relocates them to ensure A and B both work?那么当 shade 插件将 A 和 B 合并到最终的 fat jar 中时,maven 如何重新定位它们以确保 A 和 B 都工作?

This means you need a shaded version of both A and B first, both with their own relocated version of foo.bar.FooBar .这意味着您首先需要 A 和 B 的阴影版本,两者都有自己的foo.bar.FooBar定位版本。 Only this way A will be "recompiled" with its own FooBar version, and so is B. After that you can create a fat jar.只有这样 A 才会用它自己的 FooBar 版本“重新编译”,B 也是如此。之后你可以创建一个胖 jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM