我正在尝试找到一种"通用"方法,将传递依赖项排除在外,而不必将其从依赖于它的所有依赖项中排除.例如,如果我想要排除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>
Run Code Online (Sandbox Code Playgroud)
这部分是为了清理pom文件,部分是为了避免将来添加依赖于被排除依赖项的依赖项的问题 - 并且忘记排除它.
有办法吗?