【发布时间】:2019-09-21 02:01:42
【问题描述】:
这是我的父母 pom
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.fish56</groupId>
<artifactId>MavenModules</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>dao</module>
</modules>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<scope>import</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
</dependencyManagement>
这是我的子模块的 pom
<parent>
<artifactId>MavenModules</artifactId>
<groupId>com.github.fish56</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dao</artifactId>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
我希望子模块可以继承父模块的依赖,但是失败了。
我不能在我的孩子 pom 中使用 lombok 或 junit。
这是我的文件树
.
├── dao
│ ├── pom.xml
│ ├── src
│ └── target
├── pom.xml
我认为应该有一种方法可以使一些依赖项成为所有模块的分片,但我找不到解决方案。
【问题讨论】:
-
lombok 项目没有 bom,这意味着您对 lombok 项目的使用根本无法以这种方式工作。因此,只需从您的父母中删除
<scope>import</scope>。
标签: maven maven-3 dependency-management