我的项目结构如下:
.
|--module
| `-- pom.xml
| --submodule
| `-- pom.xml
`-- pom.xml
POM(简化):
- 项目:
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>project</artifactId>
<name>Project</name>
<groupId>org.myorg</groupId>
<version>1.0.6-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>module</module>
</modules>
(...)
</project>
- 模块:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.myorg</groupId>
<artifactId>project</artifactId>
<version>1.0.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>module</artifactId>
<name>Module</name>
<groupId>org.myorg</groupId>
<version>1.0.6-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>submodule</module>
</modules>
(...)
</project>
- 子模块:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.myorg</groupId>
<artifactId>module</artifactId>
<version>1.0.6-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>submodule</artifactId>
<name>Submodule</name>
<groupId>org.myorg</groupId>
<version>1.0.6-SNAPSHOT</version>
<packaging>jar</packaging>
(...)
</project>
maven install
在 POM 的项目或模块中运行时,项目已成功构建。但是,在子模块中运行时会出现此错误:
无法在项目子模块上执行目标:找不到工件 org.myorg:project:pom:1.0.6-SNAPSHOT
为什么我的子模块找不到 POM项目?指定了相对路径。