Maven耳朵项目与ejb和战争模块 [英] Maven ear project with ejb and war modules

查看:200
本文介绍了Maven耳朵项目与ejb和战争模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用maven和Jboss 7的web应用程序上工作3个模块ejb ear和war所以战争将ejb作为依赖,而ejb将同时成为耳朵的模块,所以当我这样做时我在这棵树上得到两次相同的ejb

im working on a web application with maven and Jboss 7 wich conatins 3 modules ejb ear and war so the war will have the ejb as dependancy and the ejb will be in the same time a module of the ear so when i do this i get the same ejb twice this tree

ear
...Mywar
........Myejb
...Myejb

此结构是否正确或我应该更改另一个

is this structure is correct or i should change another

战争的pom.xml:

the pom.xml for the 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>
  <groupId>tn.war.ep</groupId>
  <artifactId>businessModule</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>  
     .....
     <dependency>
    <groupId>tn.linckia.epgp</groupId>
    <artifactId>ejbModule</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>ejb</type>
    </dependency>
  </dependencies>
</project>

耳朵的pom.xml:

the pom.xml for the ear :

  <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>tn.war.ep</groupId>
  <artifactId>earModule</artifactId>
  <version>0.0.1</version>
  <packaging>ear</packaging>

  <build>
  <plugins>

    <plugin>
      <artifactId>maven-resources-plugin</artifactId>
      <version>2.4</version>
      <configuration>
        <encoding>UTF-8</encoding>
      </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.6</version>
        <configuration>
        <modules>
          <webModule>
            <groupId>tn.war.ep</groupId>
            <artifactId>businessModule</artifactId>
            <bundleFileName>businessModule.war</bundleFileName>
            <contextRoot>/businessModule</contextRoot>
          </webModule>
          <ejbModule>
            <groupId>tn.war.ep</groupId>
            <artifactId>ejbModule</artifactId>
           <bundleFileName>ejbModule.jar</bundleFileName>
          </ejbModule>
        </modules>
        <displayName>Security</displayName>
      </configuration>
    </plugin>
  </plugins>
  <finalName>AuthModule</finalName>
</build>
  <dependencies>
  <dependency>
    <groupId>tn.war.ep</groupId>
    <artifactId>businessModule</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
  </dependency>
<dependency>
            <groupId>tn.war.ep</groupId>
            <artifactId>ejbModule</artifactId>
           <version>0.0.1-SNAPSHOT</version>
          <type>ejb</type>
          </dependency>
  </dependencies>

</project>


推荐答案

配置EAR模块的正确方法是拥有EJB jar依赖于WAR模块中的提供范围,并且直接在EAR下使用EJB jar,如下所示:

Right way to configure EAR Module is to have the EJB jar dependency with "provided" scope in WAR module and having EJB jar directly under EAR like the below:

EAR
|
|-lib/someutil.jar
|-EJB.jar
|-my-web.war
|  |-WEB_INF/lib
|    |-coolutil.jar
|-EJB2.jar

但my-web.war可以依赖于任何EJB.jar,但它在运行时由容器解析。因此,在WAR的pom.xml中将ejb依赖项标记为已提供(按容器)。

But the my-web.war can dependent on the any EJB.jar, but its resolved in runtime by container. So, mark that ejb dependency as "provided" (by container) in WAR's pom.xml.

这篇关于Maven耳朵项目与ejb和战争模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆