孩子在平面结构化多模块Maven构建中找不到父Pom [英] Child not finding parent pom in flat structured multi module maven build
本文介绍了孩子在平面结构化多模块Maven构建中找不到父Pom的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在建立一个具有扁平结构的多模块项目,即父级和子级位于同一基本目录中.父级定义为
I'm setting up a multi module project with a flat structure, i.e. parent and child are in the same base directory. Parent is defined as
<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>4.0.0</modelVersion>
<groupId>company</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1-0-SNAPSHOT</version>
<name>child</name>
<modules>
<module>../child</module>
</modules>
(...)
子项定义为
<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">
<parent>
<groupId>company</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>company</groupId>
<artifactId>child/artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>child</name>
(...)
(混淆了公司和项目的名称)
正在发生的事情是模块(子代)抱怨找不到父代,即:
What's occurring is that the module (child) is complaining that it can't find the parent, i.e:
Reason: Cannot find parent: company:child for project: company:child:war:1.0-SNAPSHOT for project company:child:war:1.0-SNAPSHOT
是否有针对我遗漏的明显解决方案,还是建议使用扁平项目结构?
Is there an obvious solution to this that I've missed, or is it ill advised to use a flat project structure?
修改: 修正了错字.
推荐答案
按照 POM简介:
<project>
<parent>
<groupId>company</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>.../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>company</groupId>
<artifactId>child</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>child</name>
...
</project>
这篇关于孩子在平面结构化多模块Maven构建中找不到父Pom的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文