我有父pom,它包含了所有的项目版本和排除,我想有相同的排除从父在子,我如何实现它。
子项目继承了他父亲的版本,但拿着工件a,我想让他避免拿一个我怎么做呢?
我的目标是有一个没有依赖关系的字母jar。
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>parent-pom</artifactId>
<groupId>parent</groupId>
<version>1.0.0</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>com.somthing.ltetters</groupId>
<artifactId>ltetters</artifactId>
<version>1.4</version>
<exclusions>
<exclusion>
<groupId>com.somthing.ltetters</groupId>
<artifactId>a</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>1.0.0</modelVersion>
<artifactId>son-project</artifactId>
<packaging>war</packaging>
<version>3.9.0.SNAPSHOT</version>
<parent>
<groupId>parent-pom</groupId>
<artifactId>parent</artifactId>
<version>0.1.0</version>
</parent>
<dependencies>
<dependency>
<groupId>com.somthing.ltetters</groupId>
<artifactId>ltetters</artifactId>
</dependency>
</dependencies>
发布于 2016-01-06 19:34:54
如果您已经在父pom中指定了依赖项,那么它将被所有子构件继承,并且不需要再次指定它。如果您实际上不想默认继承它,那么应该在父pom中使用[dependencyManagement](https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management),然后在没有版本或排除的子项目中指定依赖项。因此,您的父级pom将如下所示:
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>parent-pom</artifactId>
<groupId>parent</groupId>
<version>1.0.0</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.somthing.ltetters</groupId>
<artifactId>ltetters</artifactId>
<version>1.4</version>
<exclusions>
<exclusion>
<groupId>com.somthing.ltetters</groupId>
<artifactId>a</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
...
<dependencyManagement>
...所有的子项目仍然可以看上去和你的问题一样。
https://stackoverflow.com/questions/34641215
复制相似问题