The correct way is to use the exception mechanism, but sometimes you can use the following hack instead to avoid adding a lot of exceptions when many artifacts have the same transitive dependency that you want to ignore. Instead of specifying an exception, you define an additional dependency with the amount of "provided". This tells Maven that you will manually take care of providing this artifact at runtime, and therefore it will not be packaged. For example:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.6</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> <scope>provided</scope> </dependency>
Side effect: you must specify the version of the ignored artifact, and its POM will be restored during assembly; this does not apply to regular exceptions. This can be a problem for you if you run your private Maven repository behind a firewall.
Pavel May 03 '09 at 17:19 2009-05-03 17:19
source share