简体   繁体   English

Maven-两个模块可以使用同一库的不同版本

[英]maven - can two modules use different versions of the same library

I have a java project with two maven modules (moduleA and moduleB), where each module want to access different versions (v1 and v2) of the same library. 我有一个带有两个Maven模块(moduleA和moduleB)的Java项目,其中每个模块都希望访问同一库的不同版本(v1和v2)。 moduleA uses moduleB as a dependency. moduleA使用moduleB作为依赖项。 I created moduleB mainly to get around this problem and also thought it will keep the code well organized. 我创建moduleB主要是为了解决这个问题,并且还认为它将使代码保持井井有条。

I have used maven shade plugin in moduleA's pom.xml, thinking it will help me differentiate the classes from each version but i still get "NoSuchMethodError" even though that method is available in v2 version of the library. 我在moduleA的pom.xml中使用了maven shade插件,认为它将帮助我区分每个版本的类,但是即使该方法在库的v2版本中可用,我仍然会收到“ NoSuchMethodError”。 Any help would be highly appreciated. 任何帮助将不胜感激。

我认为这行不通:如果您尝试一次将同一个库的两个不同版本加载到Java中,则会发生名称空间冲突

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

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