-
Notifications
You must be signed in to change notification settings - Fork 34
Addressing dependency clash
John Bogovic edited this page Jun 28, 2019
·
2 revisions
This example will describe how to use eclipse to find and address duplicate classes that appear in dependencies that maven finds.
- Import this maven project into eclipse
- Navigate to the folder containing the "pom.xml" file, and run
mvn
- Observe that you get the error below "No Duplicate Classes Allowed"
- Find the part of the error output telling us that it is the
regexp
andxalan
dependencies that have duplicate classes - Open the pom.xml in eclipse
- Open the "Dependency Hierarchy" tab.
- Type "xalan" into the Filter field near the top-right of the "Dependency Hierarchy" window, and see that we're depending on
xalan-2.7.1
- Right click
xalan-2.7.1
in the window, choose "Exclude maven artifact", and press "Ok" - Save the pom.xml
- Notice that the pom.xml changed - look at what it did. (
git diff
will show what the changes are) - Go back to the command line, run
mvn
and see that it works now! - If you'd like, compare with the pom.xml in the solutions folder
Notice that duplicate classes that cause the enforcer to complain were
found in the dependencies: regexp
and xalan
.
No Duplicate Classes Allowed!
- For duplicate transitive dependencies, add dependency exclusions.
- For duplications between direct dependencies, resolve or add
ignored classes to this rule's configuration.
Found in:
regexp:regexp:jar:1.3:runtime
xalan:xalan:jar:2.7.1:runtime
Duplicate classes:
org/apache/regexp/ReaderCharacterIterator.class
org/apache/regexp/REDebugCompiler.class
org/apache/regexp/REDemo.class
org/apache/regexp/RETest.class
org/apache/regexp/REUtil.class
org/apache/regexp/RESyntaxException.class
org/apache/regexp/REDemo$1.class
org/apache/regexp/RECompiler$RERange.class
org/apache/regexp/StreamCharacterIterator.class
org/apache/regexp/RECompiler.class
org/apache/regexp/StringCharacterIterator.class
org/apache/regexp/CharacterIterator.class
org/apache/regexp/recompile.class
org/apache/regexp/CharacterArrayCharacterIterator.class
org/apache/regexp/REProgram.class
org/apache/regexp/RE.class