Home > Net >  Java/Maven how to use a dependency that uses an older version of another dependency that is already
Java/Maven how to use a dependency that uses an older version of another dependency that is already

Time:11-25

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.

CodePudding user response:

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

CodePudding user response:

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.

  • Related