A solution could be to rid off mail.jar from the parent POM, but most of the projects that inherit base, need it (as is a transtive dependency for log4j). So What I would like to do is to simply exclude parent's library from the child project, as it could be done if base was a dependency and not the parent pom:... <dependency> <artifactId>base</artifactId> <groupId>es.uniovi.innova</groupId> <version>1.0.0</version> <type>pom<type> <exclusions> <exclusion> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> </exclusion> </exclusions> </dependency>...推荐答案一些想法:在这种情况下,也许您不能简单地从父级继承(并声明对 base 的依赖并排除).如果父 pom 中有很多东西,那就不太方便了.Maybe you could simply not inherit from the parent in that case (and declare a dependency on base with the exclusion). Not handy if you have lot of stuff in the parent pom.另一件要测试的事情是在 dependencyManagement 下用 ALL-DEPS 所需的版本声明 mail 工件父 pom 强制收敛(虽然我不确定这是否会解决范围问题).Another thing to test would be to declare the mail artifact with the version required by ALL-DEPS under the dependencyManagement in the parent pom to force the convergence (although I'm not sure this will solve the scoping problem).<dependencyManagement> <dependencies> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>???</version><!-- put the "right" version here --> </dependency> </dependencies></dependencyManagement>或者,如果您不使用依赖它的功能,您可以从 log4j 中排除 mail 依赖项(这就是我要做的):Or you could exclude the mail dependency from log4j if you're not using the features relying on it (and this is what I would do):<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> <scope>provided</scope> <exclusions> <exclusion> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> </exclusion> <exclusion> <groupId>javax.jms</groupId> <artifactId>jms</artifactId> </exclusion> <exclusion> <groupId>com.sun.jdmk</groupId> <artifactId>jmxtools</artifactId> </exclusion> <exclusion> <groupId>com.sun.jmx</groupId> <artifactId>jmxri</artifactId> </exclusion> </exclusions></dependency>或者你可以恢复到 log4j 的 1.2.14 版本而不是异端的 1.2.15 版本(他们为什么不将上述依赖项标记为可选?!). 这篇关于无论如何要排除从父 POM 继承的工件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-22 11:45