具有冲突依赖关系的Gradle影子罐 [英] Gradle shadow jar with conflicting dependencies

查看:142
本文介绍了具有冲突依赖关系的Gradle影子罐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算为我的服务创建超级罐子,但我担心包含具有冲突依赖关系的罐子。当jar A依赖于slf4j-1.0而jar B依赖于slf4j-2.0时会发生什么,并且1.0和2.0之间有重大更改?当那些jar都被包含在uber jar中时,我是否必须通过命名空间编写特定的过滤器,或者在影子过程中发生了什么,命名空间为jar?



感谢帮助

解决方案

您无需担心。你最终会碰到一个碰撞(一个同事把它叫做'再来一次'),有时你可以在v1和v2中的jar文件中的同一个目录中找到类。



<您可以轻松地排除其中一个或其他版本,但是如果您的依赖项需要它们,您将面临以下选择:


  • 找到一个没有冲突的新依赖关系。升级或降级当前依赖关系,以便将
  • 中的版本作为战争文件发布或一些其他类型的文件可以更好地处理这些问题,包括具有包含类路径的清单的常规jarfile

  • 考虑使用与阴影不同的策略的spring引导: http://docs.spring.io/spring-boot/docs/ current-SNAPSHOT / reference / htmlsingle /#executable-jar


    不管你做什么,gradle depe相关性很有帮助。


    I'm playing with the idea of creating uber jars for my services but I'm worried about including jars that have conflicting dependencies. What happens when jar A depends on slf4j-1.0 and jar B depends on slf4j-2.0 and there were major changes between 1.0 and 2.0? When those jars both get included in the uber jar do I have to write specific filters by namespace or does something happen during the shadow process that namespaces the jars?

    thanks for the help

    解决方案

    You are correct to worry. You end up with collisions (a colleague called it 'dll hell all over again') and sometimes you can have classes from both v1 and v2 in the same directory in the jarfile.

    You can exclude one or the other version easily, but if your dependencies need them both, you are faced with the following options:

    Whatever you do, gradle dependencies is helpful.

    这篇关于具有冲突依赖关系的Gradle影子罐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆