我试图找到一种“通用”方式来排除传递依赖项,而不必将其从依赖它的所有依赖项中排除。例如,如果我想排除 slf4j,我会执行以下操作:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jmx</artifactId>
<version>3.3.2.GA</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
这部分是为了清理 pom 文件,部分是为了避免将来人们添加依赖于排除的依赖项的依赖项而忘记排除它的问题。
有办法吗?