2011-08-30 58 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> 

干杯!