无法将EAR(及其WAR)转换为Maven

时间:2014-07-22 15:10:24

标签: maven war ear

今天我认为将我的项目转换为Maven项目是一个好主意。

我有一个包含4个WAR和3个EJB模块的EAR。关于迁移EAR项目,我关注IBM's tutorial。我最终逐一转换了所有的战争/ ejb-jars,最后是EAR。我还将战争添加到EAR作为EAR pom.xml中的依赖项。但是当我启动mvn ear:ear命令时,它会向我发出类似这样的警告:

[WARNING] The POM for server-admin-connector:server-admin-connector:war:0.0.1-SNAPSHOT is missing, no dependency information available

然后,由于此错误,构建失败:

[ERROR] Failed to execute goal on project server-ear: Could not resolve dependencies for project server-ear:server-ear:ear:0.0.1-SNAPSHOT: The following artifacts could not be resolved: server-admin-connector:server-admin-connector:war:0.0.1-SNAPSHOT

我认为IBM的文章并不完整,但我找不到任何关于将整个EAR项目迁移到Maven的其他来源。谁可以帮我这个事?我怎样才能摆脱这个错误?

编辑:我的工作区中没有特定的项目结构。这是我的项目,但是:

/server-project/
               *server-ear (EAR)
               *server-admin-connector (WAR)
               *server-adminClient (JAR - stores the shared POJOs and interfaces for admin)
               *server-business-layer (EJB)
               *server-business-layerClient (JAR - stores the shared POJOs and interfaces for the business connector)
               *server-business-connector (WAR)

我开始转换非EAR项目及其所需的依赖项。然后我使用maven ear模块将它们全部添加到耳朵的POM.xml中。 Eclipse在执行此操作时没有向我显示任何错误,因此我认为构建部分没问题。

这是EAR的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>server-ear</groupId>
<artifactId>server-ear</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<name>server-ear</name>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <earSourceDirectory>EarContent</earSourceDirectory>
                <generateApplicationXml>true</generateApplicationXml>
                <applicationXml>${project.build.directory}/application.xml</applicationXml>
                <skinnyWars>true</skinnyWars>
                <version>7</version>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <modules>
                    <ejbModule>
                        <groupId>server-business-layer</groupId>
                        <artifactId>server-business-layer</artifactId>
                    </ejbModule>
                    <webModule>
                        <groupId>server-admin-connector</groupId>
                        <artifactId>server-admin-connector</artifactId>
                        <contextRoot>/admin</contextRoot>
                    </webModule>
                    <webModule>
                        <groupId>server-intern-rest-connector</groupId>
                        <artifactId>server-intern-rest-connector</artifactId>
                        <contextRoot>/api</contextRoot>
                    </webModule>
                </modules>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>server-admin-connector</groupId>
        <artifactId>server-admin-connector</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>server-business-layer</groupId>
        <artifactId>server-business-layer</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>server-intern-rest-connector</groupId>
        <artifactId>server-intern-rest-connector</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>server-business-layerClient</groupId>
        <artifactId>server-business-layerClient</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>server-adminClient</groupId>
        <artifactId>server-adminClient</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>

1 个答案:

答案 0 :(得分:2)

我发现了我的问题。我不是一个一个地安装每个战争/罐子。不要忘记运行&#34; mvn install&#34;在尝试生成EAR之前,在所有WAR / JAR上执行命令!

我不知道我是否将此标记为答案,或者我只是删除了问题...