简体   繁体   中英

EAR is packing two copies of WAR and JAR projects

My Maven EAR project packs my EAR with two copies of each of my libraries. One copy is always appended with the version (In my case 1.0-SNAPSHOT). Is there something screwed up in my POMs?

I keep getting these type of errors when i try and deploy to server:

Servlet [blah...] and Servlet [blah..] have the same url pattern: [/RegistrationService_V10].

在此处输入图片说明

My EAR project POM looks like this :

<?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>

In the maven-ear-plugin, you have to specify your ejbmodule and 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>

Could you give us the feedback if it works better?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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