Avoiding class conflicts with maven

I am using maven-shade-plugin to create a project. However, I have a problem that I could not handle. There are two jars that have the same class, and the path is the same, aspectjweaver.jar and aspectjrt. jar, when the package is jar, I get the warning "duplicate class exists in ....". I tried using the "relocation" property to move the class, but the question is, how can I recounnize a class in two jars? Next is part of my Pom.xml. org.apache.maven.plugins Maven-shadow-plugin 1.3.1

<executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <filters> <filter> <artifact>org.aspectj:aspectjrt</artifact> <includes> <include>*</include> </includes> </filter> </filters> <relocations> <relocation> <pattern>org.aspectj</pattern> <shadedPattern>hide.org.aspectj</shadedPattern> </relocation> </relocations> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>cm.data.DatBoostrap</mainClass> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin> 
+4
source share
1 answer

you should simply exclude classes from one of the artifacts using something like this:

 <configuration> <filters> <filter> <artifact>junit:junit</artifact> <includes> <include>junit/framework/**</include> <include>org/junit/**</include> </includes> <excludes> <exclude>org/junit/experimental/**</exclude> <exclude>org/junit/runners/**</exclude> </excludes> </filter> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> 
0
source

All Articles