Exclude a Dependency in a Maven Plugin Last Updated : 02 Jul, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Excluding a dependency in a Maven plugin can be necessary to manage dependencies effectively and prevent conflicts or redundancies in the project. In this article, we will learn how to exclude a dependency in a Maven plugin using the <exclusions> tag within the <dependencies> section of the plugin configuration in the project's POM (Project Object Model) file.Prerequisites:Java Development Kit Maven InstallationIntegrated Development EnvironmentTools and Technologies:Maven RepositoryPOM FileMaven PluginsMaven ArchetypesBuild Life cycleImplementation to Exclude a Dependency in a Maven PluginIn Maven, you might want to exclude a transitive dependency included via a plugin to avoid version conflicts or redundant libraries. This can be done using the <exclusions> tag in the POM file.Let's assume you have a Maven project that uses the maven-compiler-plugin, and you want to exclude a specific dependency commons-logging that is pulled in transitively by another library. XML <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>my-app</artifactId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <dependencies> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> <version>3.0.24</version> <exclusions> <exclusion> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project> The maven-compiler-plugin is configured to compile the source code.A specific version of the plexus-utils dependency is included.The commons-io transitive dependency is excluded to avoid conflicts. Comment More infoAdvertise with us Next Article Optional Dependency in Maven M myarticzixi Follow Improve Article Tags : Advance Java Maven Similar Reads Optional Dependency in Maven Optional dependencies in Maven are used when it is difficult to break up a project into sub-modules (for whatever reason). The idea is that some dependencies are only required for specific aspects of the project and will be removed if such features are not used. Ideally, such a feature would be sepa 2 min read Maven - External Dependencies Apache Maven is a powerful and famous Build automation Tool. It is primarily used for Java-based projects. Maven uses a Project Object Model to manage project build information, project dependencies, project configuration, and project documentation. Handling External Dependencies is one of Maven's c 2 min read Conditional Dependency Management Using Maven Profiles Maven is an efficient build tool and project management tool mainly known for effectively building projects in Java. It is one of the most useful features in Maven, to effectively manage the consumers and producers of dependencies in a project. In complex projects, you might need different dependenc 4 min read Maven Dependency Management with Selenium In software testing, Selenium is a popular tool for automating web applications. Managing Selenium dependencies efficiently is crucial for ensuring smooth and consistent builds. Maven is a powerful build automation tool that effectively simplifies this process by handling project dependencies. This 5 min read Maven Dependency Scopes Maven Dependency scopes are used to specify the visibility and life cycle of a dependency in a Maven project. In Maven we have six different dependency scopes. Below we explain them by using a pom.xml file. Compile ScopeProvided ScopeRuntime ScopeTest ScopeSystem ScopeImport ScopeCompile Scope:This 3 min read Spring Boot - Dependency Management Spring Boot framework is the most popular web development framework. No doubt, it provides an abundance of essential features and a convenient way to handle those features. At the heart of Spring Boot is the 'Dependency Management' feature. Importance of Dependency ManagementCentralized Dependency M 6 min read Like