简体   繁体   English

Java / Maven如何使用使用项目中已使用的另一个依赖项的旧版本的依赖项

[英]Java/Maven how to use a dependency that uses an older version of another dependency that is already used in the project

In my project we use the version 2.9.0 of jackson-databind.在我的项目中,我们使用 2.9.0 版的 jackson-databind。 I want to use a maven dependency ( https://github.com/Jaspersoft/jrs-rest-java-client ), but it needs to use an older version of jackson-databind, because in more recents version they remove a method that the dependency calls (the exception "NoSuchMethod" is raised).我想使用 maven 依赖项( https://github.com/Jaspersoft/jrs-rest-java-client ),但它需要使用旧版本的jackson-databind,因为在最近的版本中,他们删除了一种方法依赖调用(引发异常“NoSuchMethod”)。

What to do in this case?在这种情况下该怎么办? Obviously I cannot downgrade the jackson-databind version we use in the project for other things just to please this sole dependency.显然我不能为了满足这个唯一的依赖而降级我们在项目中使用的 jackson-databind 版本。

Is there a way to keep using the recent version in my project, but make the dependency that needs the older version use the older version?有没有办法在我的项目中继续使用最新版本,但让需要旧版本的依赖项使用旧版本? In my opinion that would be the perfect solution, but I get the feeling it doesn't work that way.在我看来,这将是一个完美的解决方案,但我觉得它不是那样工作的。

Take a look at the Maven Shade Plugin: http://maven.apache.org/plugins/maven-shade-plugin/index.html Take a look at the Maven Shade Plugin: http://maven.apache.org/plugins/maven-shade-plugin/index.html

It allows you to rename the package of a version它允许您重命名一个版本的 package

Even if you find a solution to have two versions of the same dependency included in your project.即使您找到了一个解决方案,可以在您的项目中包含相同依赖项的两个版本。 You still have the problem, that when running the application in one JVM the classloader will not know which version of class is necessary now so it will load and provide the first class thats found in the class-loader-hierarchy.您仍然有问题,当在一个 JVM 中运行应用程序时,类加载器将不知道现在需要哪个版本的 class,因此它将加载并提供在类加载器中找到的第一个 class。 So you can not use two Versions of one Class in the same ClassLoader.所以你不能在同一个 ClassLoader 中使用一个 Class 的两个版本。

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

相关问题 强制maven spring boot项目使用旧版本的依赖项而不是其他依赖项的新版本 - Forcing maven spring boot project to use older version of a dependency instead of a new version from another dependency 依赖项取决于项目中已使用的旧版本库 - A dependency depends on older version of a library already used in the project 如何排除旧版本的 maven 依赖并使用它的新版本? - How to exclude older versions of maven dependency and use new version of it? 将项目用作另一个项目的Maven依赖项 - Use a project as a maven dependency for another 如何将Maven项目用作另一个Maven项目的依赖项? - How can I use a Maven project as a dependency to another Maven project? 如何在NetBeans 8上使用Maven项目的旧版Java(不是默认版本) - How to use older version of Java (not the default) with Maven project on NetBeans 8 java maven - 覆盖另一个依赖项的版本 - java maven - override version of another dependency 如何强制 java 应用程序使用 maven 依赖项的本地版本? - How to force a java app to use a local version of a maven dependency? 如何在使用 maven 的 intelliJ 项目中添加 scala 依赖项到 Java 项目 - How to add a scala dependency to a Java project in intelliJ that use maven Maven:将相同工件的旧版本添加为依赖项 - Maven: Add older version of the same artifact as dependency
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM