我不确定 Maven 是否支持。我很感激我能得到的任何帮助。
我有一个定义依赖项和排除项的父 pom。我无法更改父 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,但不会排除 spring-cloud-config-server jar,除非我在该依赖项的子级声明中重申父级排除。
我意识到我可以复制它,但这很混乱,而且我意识到将孩子的排除推给父母很容易,但随后我会迫使所有其他孩子都受到这种排除。
我希望 Maven 在父级和子级中以不同方式声明相同的依赖项时合并依赖项排除信息。
那可能吗?
在你的父 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>
在你的孩子 pom 中:
<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)