在Maven中,有时候我们需要排除父项目的依赖。这可以通过在项目的pom.xml文件中添加以下代码来实现:
<dependency>
<groupId>groupId of the dependency</groupId>
<artifactId>artifactId of the dependency</artifactId>
<version>version of the dependency</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>groupId of the excluded dependency</groupId>
<artifactId>artifactId of the excluded dependency</artifactId>
</exclusion>
</exclusions>
</dependency>
前面的<groupId>
,<artifactId>
和<version>
分别表示依赖的组ID,工件ID和版本,而后面的<exclusions>
元素用于定义需要排除的依赖性。