可以通过<exclusions>在a中声明一个元素来排除依赖项中的工件.<dependency>但在这种情况下,需要排除从父项目继承的工件.正在讨论的POM摘录如下:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>jruby</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<artifactId>base</artifactId>
<groupId>es.uniovi.innova</groupId>
<version>1.0.0</version>
</parent>
<dependencies>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>ALL-DEPS</artifactId>
<version>1.0</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
base工件,取决于 javax.mail:mail-1.4.jar,并ALL-DEPS取决于同一个库的另一个版本.由于这样的事实mail.jar,从ALL-DEPS存在于执行环境,虽然没有出口,碰撞与mail.jar那对父母,这是作用域确定为存在compile.
解决方案可能是从父POM中删除mail.jar,但是大多数继承base的项目都需要它(因为它是log4j的转换依赖项).所以我想做的是简单地从子项目中排除父项库,因为如果base是依赖项而不是父项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>
...
Run Code Online (Sandbox Code Playgroud)