我不确定这是否是Maven的支持。我很感激我能得到的任何帮助。
我有一个父pom,它定义了依赖项和排除项。我不能改变父母的观点:
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
<exclusions>
<!-- this exclusion needs to be inherited by all children -->
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</exclusion>
</exclusions>
</dependency>
然后,在子pom中,我需要从父级的相同依赖项中排除一个不同的依赖项。就像这样
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
<exclusions>
<!-- this exclusion is just for the child -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
但是,如果我这样做,子slf4j jar将被排除在外(正确),但是它不会排除server,除非我在该依赖项的子声明中重新声明父排除。
我意识到我可以复制它,但这是混乱的,我意识到把孩子的排斥推到父母身上是很容易的,但是我会把这种排斥强加给所有其他孩子。
我希望Maven在父级和子级中声明相同的依赖项时合并依赖项排除信息。
这有可能吗?
发布于 2016-10-17 05:59:13
在你父母的pom中:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
<exclusions>
<!-- this exclusion needs to be inherited by all children -->
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
在你的孩子身上:
<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<exclusions>
<!-- this exclusion is just for the child -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
https://stackoverflow.com/questions/39835372
复制相似问题