POM file for package EAR

<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>eden</artifactId>
        <groupId>com.conquer.eden</groupId>
        <version>1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <packaging>ear</packaging>

    <artifactId>ear</artifactId>

    <dependencies>
        <dependency>
            <groupId>com.conquer.eden</groupId>
            <artifactId>ejb3</artifactId>
            <version>1.0</version>
            <type>ejb</type>
        </dependency>
        <dependency>
            <groupId>com.conquer.eden</groupId>
            <artifactId>webdemo</artifactId>
            <version>1.0</version>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <finalName>${artifactId}</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <!--<generateModuleId>true</generateModuleId>-->

                    <!--指定打包范围,避免无用jar混乱加入-->
                    <!--<packagingIncludes>META-INF/**,**/acme-*.jar,**/acme-*.war</packagingIncludes>-->
                    <!--<packagingExcludes></packagingExcludes>-->

                    <!--打包指定目录lib-->
                    <defaultLibBundleDir>lib/</defaultLibBundleDir>
                    <!--将多个war的共享包提取到父级别-->
                    <skinnyWars>true</skinnyWars>

                    <!--<includeLibInApplicationXml>true</includeLibInApplicationXml>-->

                    <!--jboss 定制-->
                    <!--<jboss>-->
                        <!--<version>5</version>-->
                        <!--<module-order>strict</module-order>-->
                        <!--<unauthenticated-principal>guest</unauthenticated-principal>-->
                        <!--<loader-repository>com.foo:loader=foo-application-1.0.ear</loader-repository>-->
                    <!--</jboss>-->

                    <modules>

                        <!--jarModule:用于添加第三方库,配合includeInApplicationXml,可使其像一个开发的模块-->
                        <jarModule>
                            <!--<groupId>com.conquer.eden</groupId>-->
                            <!--<artifactId>ejb3</artifactId>-->
                            <!--<bundleFileName>ejb3.jar</bundleFileName>-->

                            <!--<includeInApplicationXml>true</includeInApplicationXml>-->

                            <!--<bundleDir>APP-INF/lib</bundleDir> 只更改位置,名称保持不变-->
                            <!--<uri>APP-INF/lib/anotherName-1.2.3.jar</uri> 可定制位置和名称,需要指定名称-->
                            <!--<excluded>true</excluded>-->

                            <!--<moduleId>ejb3-id</moduleId>-->
                        </jarModule>
                        <ejbModule>
                            <groupId>com.conquer.eden</groupId>
                            <artifactId>ejb3</artifactId>
                            <bundleFileName>ejb3.jar</bundleFileName>
                        </ejbModule>
                        <webModule>
                            <groupId>com.conquer.eden</groupId>
                            <artifactId>webdemo</artifactId>
                            <bundleFileName>webdemo.war</bundleFileName>

                            <!--<moduleId>webdemo-id</moduleId>-->
                        </webModule>
                    </modules>
                    <!--<security>-->
                        <!--<security-role id="SecurityRole_1234">-->
                            <!--<role-name>manager</role-name>-->
                        <!--</security-role>-->
                        <!--<security-role id="SecurityRole_5678">-->
                            <!--<description>My cool description</description>-->
                            <!--<role-name id="RoleName_12">teller</role-name>-->
                        <!--</security-role>-->
                    <!--</security>-->

                    <!--<version>6</version>-->
                    <!--<env-entries>-->
                        <!--<env-entry>-->
                            <!--<description>A complete entry.</description>-->
                            <!--<env-entry-name>complete</env-entry-name>-->
                            <!--<env-entry-type>java.lang.Integer</env-entry-type>-->
                            <!--<env-entry-value>4</env-entry-value>-->
                        <!--</env-entry>-->
                        <!--<env-entry>-->
                            <!--<env-entry-name>no-type</env-entry-name>-->
                            <!--<env-entry-value>4</env-entry-value>-->
                        <!--</env-entry>-->
                        <!--<env-entry>-->
                            <!--<env-entry-name>no-value</env-entry-name>-->
                            <!--<env-entry-type>java.lang.String</env-entry-type>-->
                        <!--</env-entry>-->
                    <!--</env-entries>-->

                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

以上pom要注意的是:

1.添加的两个依赖一个是ejb,一个是war包,指明的类型分别是:

<type>ejb</type>和<type>war</type>

2.EAR的打包插件

 

<artifactId>maven-ear-plugin</artifactId>

3.添加的ejb和war需要分别指明:<ejbModule> 和 <webModule> 并且都可以定制打进ear的名称,通过:<bundleFileName>

 

执行ear模块的package目标或执行ear模块maven的ear:ear可完成 ear的打包工作。

 

关于 maven-ear-plugin ,官网参考:http://maven.apache.org/plugins/maven-ear-plugin/

===================================================

<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.tgb</groupId>
                   <artifactId>gxpt</artifactId>
                   <version>0.0.1-SNAPSHOT</version>
                   <relativePath>../gxpt/pom.xml</relativePath>
         </parent>
         <artifactId>gxpt_a_ear</artifactId>
         <packaging>ear</packaging>
 
         <dependencies>
                  <dependency>
                            <groupId>com.tgb</groupId>
                            <artifactId>gxpt_entity_qx</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <type>jar</type>
                   </dependency>
                   <dependency>
                            <groupId>com.tgb</groupId>
                            <artifactId>gxpt_common_tool</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <type>jar</type>
                   </dependency>
                   <dependency>
                            <groupId>com.tgb</groupId>
                            <artifactId>gxpt_common_eao</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <type>jar</type>
                   </dependency>
                   <dependency>
                            <groupId>com.tgb</groupId>
                            <artifactId>gxpt_common_eao_impl</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <type>jar</type>
                   </dependency>
                   <dependency>
                            <groupId>com.tgb</groupId>
                            <artifactId>gxpt_mgr_qx_module</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <type>jar</type>
                   </dependency>
                   <dependency>
                            <groupId>com.tgb</groupId>
                            <artifactId>gxpt_mgr_qx_module_impl</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <type>jar</type>
                   </dependency>
                   <dependency>
                            <groupId>com.tgb</groupId>
                            <artifactId>gxpt_web_qx_module</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <type>war</type>
                   </dependency>
         </dependencies>
 
         <build>
                   <plugins>
                            <plugin>
                                     <artifactId>maven-ear-plugin</artifactId>
                                     <version>2.9</version>
                                     <configuration>
                                              <packagingIncludes>META-INF/**,**/gxpt_*.jar,**/gxpt_*.war</packagingIncludes>
                                               <jboss>
                                                        <version>5</version>
                                                        <module-order>strict</module-order>
                                               </jboss>
                                               <modules>
                                                        <jarModule>
                                                                 <groupId>com.tgb</groupId>
                                                                 <artifactId>gxpt_entity_qx</artifactId>
                                                                 <includeInApplicationXml>true</includeInApplicationXml>
                                                        </jarModule>
                                                        <jarModule>
                                                                 <groupId>com.tgb</groupId>
                                                                 <artifactId>gxpt_common_tool</artifactId>
                                                                 <includeInApplicationXml>true</includeInApplicationXml>
                                                        </jarModule>
                                                        <jarModule>
                                                                 <groupId>com.tgb</groupId>
                                                                 <artifactId>gxpt_common_eao</artifactId>
                                                                 <includeInApplicationXml>true</includeInApplicationXml>
                                                        </jarModule>
                                                        <jarModule>
                                                                 <groupId>com.tgb</groupId>
                                                                 <artifactId>gxpt_common_eao_impl</artifactId>
                                                                 <includeInApplicationXml>true</includeInApplicationXml>
                                                        </jarModule>
                                                        <jarModule>
                                                                 <groupId>com.tgb</groupId>
                                                                 <artifactId>gxpt_mgr_qx_module</artifactId>
                                                                 <includeInApplicationXml>true</includeInApplicationXml>
                                                        </jarModule>
                                                        <jarModule>
                                                                 <groupId>com.tgb</groupId>
                                                                 <artifactId>gxpt_mgr_qx_module_impl</artifactId>
                                                                 <includeInApplicationXml>true</includeInApplicationXml>
                                                        </jarModule>
                                                        <webModule>
                                                                 <groupId>com.tgb</groupId>
                                                                 <artifactId>gxpt_web_qx_module</artifactId>
                                                                 <includeInApplicationXml>true</includeInApplicationXml>
                                                        </webModule>
                                               </modules>
                                     </configuration>
                            </plugin>
                   </plugins>
         </build>
</project>

1.       运行ear: generate-application-xml,会生成相应的application.xml文件

2.       现在可以执行生成ear的命令了:ear:ear,坐等成功吧~~

 

posted @ 2017-08-16 22:10  Happy2Share  阅读(341)  评论(0)    收藏  举报