Java Maven子模块不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26021141/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 01:43:02  来源:igfitidea点击:

Maven child module does not exist

javamaven

提问by Mike

I'm new to Maven. I checked out from SVN a project from a customer with the following structure:

我是 Maven 的新手。我从 SVN 签出了一个来自客户的项目,其结构如下:

projectName
|--> pom.xml
|--> jetty-wrapper
     |--> pom.xml
     |--> bin
          |--> pom.xml
|--> projectName-common
     |--> pom.xml
     |--> bin
          |--> pom.xml
|--> projectName-war
     |--> bin
          |--> pom.xml

the pom.xml right below 'projectName` (the pom at the top) is building the three modules

'projectName`(顶部的 pom)正下方的 pom.xml 正在构建三个模块

<modules>
    <module>projectName-common</module>
    <module>projectName-war</module>
    <module>jetty-wrapper</module>
</modules>

But when executing mvn clean installfrom folder projectNameit gives the following error

但是当mvn clean install从文件夹执行时,projectName它会出现以下错误

Child module [...]projectName\projectName-war\pom.xml of [...]projectName\pom.xml does not exist

The question is: Should there be a pom.xml right below projectName-warjust like with the rest of the modules that my customer may have forgotten to commit to SVN?

问题是:下面是否应该有一个 pom.xmlprojectName-war就像我的客户可能忘记提交给 SVN 的其他模块一样?

采纳答案by tmarwen

The question is: Should there be a pom.xml right below projectName-war

问题是:projectName-war 下方是否应该有一个 pom.xml

Simply put yes.

简单地说

You have already figured out the trick, and since you haven't provided a project descriptor aka pom.xmlto maven, it won't be able to call the projectName-wara valid child module.

您已经找到了诀窍,并且由于您没有向 maven提供项目描述符 aka pom.xml,因此它无法将projectName-war称为有效的子模块。

There must absolutely be a pom.xmlfile under projectName-war, and it must have an artifact id that matches the one under the parent declaring the module, i.e.

projectName-war下绝对必须有一个pom.xml文件,并且它必须具有与声明模块的父项下的工件 ID 相匹配的工件 ID,即

<artifactId>projectName-war</artifactId>

回答by satish.kanikaram

Child module [...]projectName\projectName-war\pom.xml of [...]projectName\pom.xml does not exist

If you are getting the above error when using mvn install from command line (the same pom may work in eclipse) you have to change your pom.xml little

如果从命令行使用 mvn install 时遇到上述错误(相同的 pom 可能在 eclipse 中工作),则必须稍微更改 pom.xml

Instead of the below:

而不是下面的:

<modules>
        <module>../my-util</module>
        <module>../my-server</module>           
</modules>

Follow the below (enclose in a profilers):

按照以下操作(附在分析器中):

<profiles>
    <profile>
        <modules>
            <module>../my-util</module>
            <module>../my-server</module>           
        </modules>
    </profile>
</profiles>

回答by Santhosh Ponnam

This issue usually comes when you copy and paste the child projects
For example, We have individual child projects as below
<artifactId>business-layer</artifactId> with project name as business-layer
<artifactId>service-layer</artifactId> with project name as **xyz**-layer
<modules>
        <module>business-layer</module>
        <module>**service-layer**</module>
</modules>

You project name during the initial build should be same as the module name. This need not require the <profiles> tag to be added as the purpose of profiles tag is to trigger builds with specific actions