How to exclude specific class from a Maven dependency ( Jar dependency).
I have an issue with ObjectUtils.class from avro-tools.jar which is picked in run time that does not have method which is used from commons-lang3 jar. Which causing runtime NoSuchMethod error.
I wanted to know is there any way i can specify in my pom.xml to exclude this class org.apache.commons.lang3.ObjectUtils from avro-tools.jar (1.9.1) version and pick it from commons-lang3.jar (3.9 version)
try maven-shade-plugin,it will remove class from final jar generated by pom.xml
Note :- Removing particular class from jar is not possible.
<profiles>
<profile>
<id>TestShadeProfile</id>
<dependencies>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-tools</artifactId>
<version>1.9.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>org.apache.avro:avro-tools</artifact>
<excludes>
<exclude>org/apache/commons/lang3/ObjectUtils*</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
hope it will help you
mvn clean package -P TestShadeProfile
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.