2011-08-30 60 views
0

我已經用Maven,Eclipse,WTP設置了多模塊環境。 我安裝了Eclipse插件是:如何避免Maven啓用WTP項目自動生成web.xml?

  • M2E

  • M2E-額外

  • M2E疊加

我有一戰模塊(W2 )取決於另一個戰爭模塊(w1),w1有一個web.xm l文件,並且w2沒有它自己的文件,它使用來自w1的覆蓋web.xml。每當我點擊maven - >更新項目配置時,eclipse自動爲w2生成一個空的web.xml,我真的不想這樣做。

如何禁用此功能?

回答

1

缺省情況下,M2E-WTP特別要求WTP到如果不存在,並且默認(或3.0,如果在類路徑中檢測到一些的JavaEE 6依賴性)增加了動態Web刻面2.5不產生一個web.xml。 WTP創建web.xml的唯一原因是如果我們要求安裝版面< = 2.4。但是這些方面只能從現有的web.xml中推斷出來。看到諷刺?

所以你看到的是最有可能的一個錯誤,你可能要創建一個連接到https://issues.sonatype.org/browse/MECLIPSEWTP

在平均時間的樣本項目中的bug報告,你可以嘗試使用M2E-WTP 0.14的開發建設.0,可從http://download.jboss.org/jbosstools/builds/staging/m2eclipse-wtp-e37/all/repo/獲得,因爲我最近對Dynamic Facet版本更改的處理方式進行了更改。

而對於第一個回覆中描述的覆蓋排除配置,由於您想專門使用w1的web.xml,因此不適用於您,不排除它。我寧願反轉疊加順序,如:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-war-plugin</artifactId> 
    <configuration> 
    <overlays> 
     <overlay> 
     <groupId>foo.bar</groupId> 
     <artifactId>w1</artifactId> 
     </overlay> 
     <overlay> 
     <!-- this is the current w2, 
       it's resources will be overridden by w1 
      --> 
     </overlay> 
    </overlays> 
    </configuration> 
</plugin> 
1

你可以做的是 - 明確排除的相關模塊的web.xml和包裝時,它會選擇從父戰爭XML:

<build> 
    <plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> 
     <configuration> 
     <overlays> 
     <!-- Overlay w2 WAR with w1 specific web.xml --> 
      <overlay> 
      <groupId>xyz</groupId> 
      <artifactId>w1</artifactId> 
      <excludes> 
       <exclude>WEB-INF/web.xml</exclude> 
      </excludes> 
      </overlay> 
     </overlays> 
     </configuration> 
    </plugin> 
    </plugins> 
</build> 

乾杯!