2013-02-16 73 views
0

我是新來創造之間的戰爭和罐子之間的溝通和溝通...戰爭與內耳之間的溝通

我有兩個戰爭具有完全獨立的功能。 現在我必須創建一個耳朵,其中兩個應用程序必須在相同的功能上工作, 它被包含在一個jar中。但要求是我不能在兩個包含Pom.xml的jar中使用該jar,所有3個都在單耳下。這可能嗎? 我已經測試了兩次獨立戰爭的耳朵,它現在工作正常,上面如何實現我沒有得到這個。
我使用Maven和Jboss7.1.1。
我通過鏈接像MessageHandler in JAR/WAR/EARhttps://stackoverflow.com/questions/1796255/tell-me-a-clear-differnece-between-ear-war-and-jar,但不知道上述問題。

回答

0
Hi got the solution >> here it is.. this is a pom.xml of ear project 


<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>Test</groupId> 
    <artifactId>Test</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>ear</packaging> 

<dependencies> 
    <!--Dependency for jar--> 
    <dependency> 
     <groupId>com.jar</groupId> 
     <artifactId>com.jar</artifactId> 
     <version>1.0</version> 
     <type>war</type> 
    </dependency> 
    <!--Dependency for war1--> 
    <dependency> 
     <groupId>com.war2</groupId> 
     <artifactId>com.war2</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
     <type>war</type> 
    </dependency>  
    <!--Dependency for war2--> 
    <dependency> 
     <groupId>com.war1</groupId> 
     <artifactId>com.war1</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
     <type>war</type> 
    </dependency> 
</dependencies> 

<build> 
    <finalName>Project</finalName> 
    <plugins> 
     <plugin> 
      <artifactId>maven-ear-plugin</artifactId> 
      <version>2.8</version> 
      <configuration> 
       <finalName>MyEarFile</finalName> 
       <version>5</version> 
       <modules> 
        <!--Webmodule for war1--> 
        <webModule> 
         <groupId>com.war1</groupId> 
         <artifactId>com.war1</artifactId> 
         <uri>war1.war</uri> 
         <bundleFileName>war1.war</bundleFileName> 
        </webModule> 

        <!--Webmodule for war2--> 
        <webModule> 
         <groupId>com.war2</groupId> 
         <artifactId>com.war2</artifactId> 
         <uri>war2.war</uri> 
         <bundleFileName>war2.war</bundleFileName> 
        </webModule> 
       </modules> 
      </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 




Note:: groupId and artifactId metioned here must match with groupId and artifactId mentioned in the project's pom.xml. 
Also dependency of jar must be present in this i.e. ear's pom.xml and not in both app's pom.xml. 
At time of maven install it automatically refers to jar's contents.. 
0

你可以將多個戰爭和罐子放入耳朵,他們可以共享同一個類加載器。這意味着所有的課程都可以從所有的罐子/戰爭中獲得。即好像所有的類/資源都在一個檔案中而沒有子包裝。

我假設這是你所說的「戰爭與罐子之間的溝通」。

編輯:檢查Making an EAR with Maven作爲構建耳朵的pom.xml的示例。在這個例子中,有一個罐子和一個戰爭,但你可以有任何數量的戰爭/罐子。

+0

感謝您的回覆我是新來this.http://stackoverflow.com/questions/5337784/separate-same-jars-in-different-war-of-a-ear我想是這樣這是兩個應用程序訪問相同的jar。但我沒有得到如何使用'maven'來完成這項工作。 – vg123 2013-02-16 11:16:02

+0

也一旦依賴的應用程序,從pom.xml中刪除,那麼它不會創建戰爭,然後如何通過從耳朵提供參考jar來創建戰爭? – vg123 2013-02-16 11:24:34

+0

如果我理解你的問題,那麼你只需參考構建耳朵的pom中的罐子/戰爭。 – 2013-02-16 11:40:41