父pom.xml的无效包装,必须是“甲醛”,但“耳朵”(Invalid packaging for

2019-08-02 14:32发布

可能有人建议我用以下异常的解决方案。 我要创建一个多模块项目。

父项目名称是LOGICBACKEND子项目名称是DBAccess

我需要的EAR文件LOGICBACKEND它应该包含DBAccess prjoects jar文件。

我得到以下情况例外,当我运行mav clean install -P Developer

[ERROR]The project com.project1.Database:DBAccess:1.0-SNAPSHOT (C:\Project1\DBAccess\pom.xml) has 1 error
[ERROR]Invalid packaging for parent POM com.project1.logic:LOGIC:1.0-SNAPSHOT (C:\Project1\pom.xml), must be "pom" but is "ear" @ com.project1.logic:LOGIC:1.0-SNAPSHOT, C:\Project1\pom.xml, line 6, column 13

这是我父母的pom.xml长相如何组成部分

<modelVersion>4.0.0</modelVersion>
<groupId>com.project1.logic</groupId>
<artifactId>LOGICBACKEND</artifactId>
<packaging>ear</packaging>
<version>1.0-SNAPSHOT</version> 

这是孩子的pom.xml的样子

<groupId>com.project1.logic</groupId>
<artifactId>DBAccess</artifactId>
<packaging>ejb</packaging>
<name>DBAccess</name>
<version>1.0-SNAPSHOT</version>

<parent>
    <groupId>com.project1.logic</groupId>
    <artifactId>DBAccess</artifactId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
</parent>

任何人可以帮助我在这里要明白是怎么回事错在这里。

在此先感谢您的帮助

Answer 1:

这个简单的设置是一个良好的开端。

.
├── pom.xml
├── services
|   ├── pom.xml
|   └── src
|       └── main
|           └── java
|               └── com
|                   └── stackoverflow
|                       └── MyEjbService.java
└── application
    └── 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>

    <groupId>com.stackoverflow.Q13330930</groupId>
    <artifactId>parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>${project.artifactId}-${project.version}</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <modules>
        <module>services</module>
        <module>application</module>
    </modules>

    <dependencies>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.stackoverflow.Q13330930</groupId>
                <artifactId>services</artifactId>
                <version>${project.version}</version>
                <type>ejb</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

services/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.stackoverflow.Q13330930</groupId>
        <artifactId>parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <groupId>com.stackoverflow.Q13330930</groupId>
    <artifactId>services</artifactId>
    <packaging>ejb</packaging>

    <name>${project.artifactId}-${project.version}</name>

</project>

application/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.stackoverflow.Q13330930</groupId>
        <artifactId>parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <groupId>com.stackoverflow.Q13330930</groupId>
    <artifactId>application</artifactId>
    <packaging>ear</packaging>

    <name>${project.artifactId}-${project.version}</name>

    <dependencies>
        <dependency>
            <groupId>com.stackoverflow.Q13330930</groupId>
            <artifactId>services</artifactId>
            <type>ejb</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>


Answer 2:

您正在试图给父POM两大功能-这是作为一个父POM(包装pom )和被包装的耳朵(包装ear ) -在同一时间。 为了解决您的问题,你应该有你的包装父POM下创建另一个行家模块ear ,并使用Maven的耳插件定义输出。



文章来源: Invalid packaging for parent pom.xml, must be “pom” but is “ear”