EAR正在打包两份WAR和JAR项目

时间:2013-11-21 14:53:26

标签: java maven java-ee netbeans glassfish

我的Maven EAR项目将我的EAR包含在我的每个库的两个副本中。一个副本始终附加版本(在我的情况下为1.0-SNAPSHOT)。我的POM中有什么东西搞砸了吗?

当我尝试部署到服务器时,我不断收到这些类型的错误:

Servlet [blah ...]和Servlet [blah ..]具有相同的url模式:[/ RegistrationService_V10]。

enter image description here

我的EAR项目POM看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <parent>
        <artifactId>AlmexOffice</artifactId>
        <groupId>com.huwag</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.huwag</groupId>
    <artifactId>AlmexOffice-ear</artifactId>
    <packaging>ear</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>AlmexOFfice-ear JavaEE6 Assembly</name>
    <url>http://maven.apache.org</url>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <version>6</version>
                </configuration>
            </plugin>
        </plugins>
        <finalName>AlmexOffice-ear</finalName>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.huwag</groupId>
            <artifactId>AlmexOffice-ejb</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>ejb</type>
        </dependency>
        <dependency>
            <groupId>com.huwag</groupId>
            <artifactId>AlmexOffice-web</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>war</type>
        </dependency>
    </dependencies>
</project>

1 个答案:

答案 0 :(得分:1)

在maven-ear-plugin中,你必须指定你的ejbmodule和webmodule

<plugin>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.8</version>
    <configuration>
      <modules>
        <ejbModule>
           <groupId>com.huwag</groupId>
           <artifactId>AlmexOffice-ejb</artifactId>
        </ejbModule>
        <webModule>
           <groupId>com.huwag</groupId>
           <artifactId>AlmexOffice-web</artifactId>
           <contextRoot>/custom-context-root</contextRoot>
         </webModule>
      </modules>
    </configuration>
</plugin>

如果效果更好,你能否给我们反馈意见?