简体   繁体   中英

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. 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).

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.

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

It allows you to rename the package of a version

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. So you can not use two Versions of one Class in the same ClassLoader.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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