简体   繁体   English

使用Java从Maven多模块项目创建War文件失败

[英]Creating war file failed from maven multi module project using java

I have a parent maven project and two child modules of that parent. 我有一个父级maven project和该父级的two child modules One of the child modules has a packaging type of jar . 子模块之一具有packaging type of jarpackaging type of jar And this jar is to be used in the other child module which has packaging type of war. 并且此jar将用于具有packaging type of war.的其他子模块packaging type of war.

First child's pom.xml: 第一个孩子的pom.xml:

<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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <groupId>com.zurel.myParent</groupId>
        <artifactId>myParent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
      </parent>
      <artifactId>myFirstChild</artifactId>
      <packaging>jar</packaging>
</project>

Second child's pom.xml: 第二个孩子的pom.xml:

 <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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <groupId>com.zurel.myParent</groupId>
        <artifactId>myParent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
      </parent>
      <artifactId>myFirst</artifactId>
      <packaging>war</packaging>

    <dependencies>

            <!--other dependencies -->
            <dependency>
                 <groupId>com.zurel.myParent</groupId>
                <artifactId>myFirstChild</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </dependency>
    </dependencies>
    </project>

When I try to run package command in the second maven module, I get the following error: 当我尝试在第二个maven模块中运行package命令时,出现以下错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myFirst 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.zurel.myParent:myFirstChild:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.353s
[INFO] Finished at: Thu Jun 19 16:20:58 NPT 2014
[INFO] Final Memory: 5M/100M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project myFirst: Could not resolve dependencies for project com.zurel.myParent:myFirst:war:0.0.1-SNAPSHOT: Could not find artifact com.zurel.myParent:myFirstChild:jar:0.0.1-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

pom of both the child modules look fine. 两个子模块的pom看起来都很好。 However, Kindly ensure following is done: 1) Both child modules are added in the parent module (aggregator module) as modules 2) the aggregation module has packaging type of 'pom' 但是,请确保执行以下操作:1)两个子模块都作为模块添加到父模块(聚合器模块)中2)聚合模块的包装类型为'pom'
3) Run 'mvn clean install on parent module 3)在父模块上运行'mvn clean install

Sample parent pom : 父pom示例:

http://maven.apache.org/maven-v4_0_0.xsd"> http://maven.apache.org/maven-v4_0_0.xsd“>

   <modelVersion>4.0.0</modelVersion>
   <groupId>org.test</groupId>
   <artifactId>myParent</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>myParent</name>
    <url>http://maven.apache.org</url>

   <modules>
    <module>../FirstChild</module>
    <module>../SecondChild</module>
   </modules>

You are missing "First child" dependency. 您缺少“第一个孩子”依赖项。
Do you have registered both modules in myParent? 您是否已在myParent中注册了两个模块? Is the order is so that "First child" builds first? 是为了使“第一个孩子”首先建造的顺序?
What command do you execute? 您执行什么命令? It should "mvn install" 它应该“ MVN安装”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM