简体   繁体   English

maven 依赖管理和传递依赖的版本变更

[英]maven dependency managment and version change of transitive dependency

How to safely manage with such a problem:如何安全地管理此类问题:

In maven we have 2 libs (A with version 20, B with version 30) that depends on C (1.0 and 1.1 respectively).在 maven 中,我们有 2 个依赖于 C(分别为 1.0 和 1.1)的库(A 版本为 20,B 版本为 30)。 We get jar hell in target libs我们在目标库中得到了 jar 地狱

*--A20--C1.0
\--B30--C1.1

Then I add dependencyManagment section and force C version to 1.1.然后我添加dependencyManagment 部分并强制C 版本为1.1。 It works as expected.它按预期工作。

*--A20--C1.1 (not C1.0)
\--B30--C1.1

After several months, we decide to upgrade A to version 50. Now it depends on C version 2.0.几个月后,我们决定将 A 升级到 50 版。现在它依赖于 C 2.0 版。 But project still uses 1.1 due to dependencyManagement.但是由于依赖管理,项目仍然使用 1.1。 It's a problem now现在是个问题

*--A50--C1.1 (not C2.0 as needed)
\--B30--C1.1

The question is: is it possible to override transitive dependency and this override will work only if version of transitive dependency match the version we set?问题是:是否可以覆盖传递依赖,并且只有传递依赖的版本与我们设置的版本匹配时,这个覆盖才会起作用? Otherwise this override will be ignored and we'll see an error (with help of maven-enforcer plugin, for instance) I wonder if we have some plugin to check this case?否则这个覆盖将被忽略,我们会看到一个错误(例如在 maven-enforcer 插件的帮助下)我想知道我们是否有一些插件来检查这种情况?

No.不。

I understand your use case, but I do not see anything in Maven to produce the result you want.我了解您的用例,但我在 Maven 中看不到任何东西可以产生您想要的结果。

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

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