Maven Tip #2 - Exclude a transitive dependency

Sometimes when you are using Maven one of your dependencies might be pulling in a dependency of its own that you do not want to use.


    <dependency>
        <groupId>mycompany</groupId>
        <artifactId>myproduct</artifactId>
        <version>1.0</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
               <groupId>mycompany</groupId>
                <artifactId>mylibrary</artifactId>
            </exclusion>
        </exclusions> 
    </dependency>
        

And voila you have excluded the dependency.

Posted December 8, 2016

Up