[MAVEN] - Package a Web Application into EAR

本文指导如何使用Maven创建并配置企业级应用项目,包含创建仅包含JavaWeb应用(WAR)的企业应用Maven项目,以及相关依赖、打包方式和上下文根配置。

Java packaging file types

JAR - Java Archive

WAR - Web Archive

EAR - Enterprise Archive. For assembling Java EE modules.

A WAR or EAR file is a standard JAR file with a .war or .ear extension. They are all for assembling or packaging components or modules. 

An EAR file contains (or assembles) Java EE modules (JARs and WARs) and, optionally, deployment descriptors inside META-INF. There're two types of deployment descriptors, Java EE (application.xml) and runtime (specified by application server).


Enterprise Application MAVEN Project Creation

Create a  enterprise application maven project which contains only one Java Web Application (WAR).

<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.martian.wbbank</groupId>
        <artifactId>wbbank-root</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <groupId>com.martian.wbbank.interfacelayer</groupId>
    <artifactId>wbbank-spring-ear</artifactId>
    <packaging>ear</packaging>
    <name>wbbank-spring-ear</name>

    <dependencies>
        <dependency>
            <groupId>com.martian.wbbank.interfacelayer</groupId>
            <artifactId>wbbank-spring</artifactId>
            <type>war</type>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <modules>
                        <webModule>
                            <groupId>com.martian.wbbank.interfacelayer</groupId>
                            <artifactId>wbbank-spring</artifactId>
                            <strong><contextRoot>/wbbank</contextRoot></strong>
                        </webModule>
                    </modules>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

*** We also modify the context root of this web application instead of default value. 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值