Excluding a dependency in Maven means preventing a specific transitive dependency pulled in by a direct dependency from being added to your project's classpath. This is done with the <exclusions> element nested inside a <dependency> declaration.
A project using spring-boot-starter-logging alongside another library that transitively pulls in commons-logging can exclude commons-logging from that library to avoid classpath conflicts with SLF4J.
<dependency>
<groupId>com.example</groupId>
<artifactId>some-library</artifactId>
<version>2.1.0</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>A concise interview answer is
You exclude a transitive dependency by adding an exclusions block inside the dependency that's pulling it in, specifying the groupId and artifactId to exclude. This is typically used to resolve version conflicts, like avoiding a duplicate logging implementation on the classpath.
Last updated: 16 July 2026
Previous question: What is a Maven repository?
Next question: How can we optimize a Maven build for a large project?