问题
My application is defined with an external library jar dependency
<dependency>
<groupId>com.lib</groupId>
<artifactId>Encoder</artifactId>
</dependency>
It has two versions 1.0 and 2.0. A class owned in the library got updated in its package structure between these versions as below.
1.0 -- a.b.c.Template
2.0 -- x.y.z.Template
Another dependency called 'Helper' used in my application also contains the above stated Encoder library, but with version 1.0.
Now, my application is defined with 'Encoder' library version 2.0 along with 'Helper' dependency.
My application usage of Encoder library
import x.y.z.Template
..
The 'Helper' dependency usage of Encoder library
import a.b.c.Template
..
The code build is failing with class file not found error as like below.
cannot access a.b.c.Template class file for a.b.c.Template not found
Appreciate your help on finding a solution for the same. Thanks in advance!
回答1:
The best is to avoid above situation by carefully picking dependency versions until everything runs smoothly.
If this is too difficult, you can have a look at the maven-shade-plugin, which allows you to relocate packages that are merged into a dependency.
来源:https://stackoverflow.com/questions/60396734/maven-dependency-incompatible-library-class