Maven
dependency in maven
- Problem
An error happened when build a Spring project:
java.lang.LinkageError: ClassCastException: attempting to castjar:file: ....../javax.ws-api-2.0.1-jar to ....../javax.ws-api-2.0.1-jar //(the absolute path of the two file is the same )
- Reason
It seems like there are two library depends on the same jar(javax.ws-api-2.0.1-jar), but the way they package dependency is not the same.
- Solution
One way i found is remove the “shaded” from dependency declaration.
Old format:
<dependency>
<groupId>com.spotify</groupId>
<artifactId>docker-client</artifactId>
<classifier>shaded</classifier>
<version>8.9.0</version>
...
</dependency>
Updated format:
<dependency>
<groupId>com.spotify</groupId>
<artifactId>docker-client</artifactId>
<version>8.9.0</version>
...
</dependency>
Reference
maven-shade-plugin: Repackages the project classes together with their dependencies into a single uber-jar, optionally renaming classes or removing unused classes.