
[英]Disable Maven warning message - “Selected war files include a WEB-INF/web.xml which will be ignored”
[英]Maven: creating 2 war files each with different web.xml?
我需要使用Maven创建两个包含两个不同web.xml
文件的WAR文件。 否则WAR文件是相同的。
WAR文件按预期创建,但是,第二个文件与第一个文件具有相同的web.xml
文件。
如何强制Maven WAR插件将第二个文件用于第二个WAR? 我不能使用配置文件,因为我需要在一次传递中创建两个文件。
我目前的代码:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warSourceDirectory>${basedir}/WEB</warSourceDirectory>
<warName>main</warName>
<webXml>${basedir}/CONF/web.xml</webXml>
</configuration>
<executions>
<execution>
<id>hist-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<warName>hist</warName>
<warSourceDirectory>${basedir}/WEB</warSourceDirectory>
<webXml>${basedir}/CONF/hist.web.xml</webXml>
</configuration>
</execution>
</executions>
</plugin>
使用Maven WAR插件的叠加功能。
您需要两个WAR项目。 第一个是您的原始文件,其web.xml
文件位于正确的位置。 这在配置方面没有任何特定需求。 确保按照您的预期构建它。
第二个只包含其POM和WEB-INF
目录中的备用web.xml
。 此项目的POM必须包含对第一个项目的依赖关系,其类型指定为war,范围指定为runtime。 您不需要显式配置Maven WAR插件。
似乎有各种各样的使用war插件的陷阱。 在这种情况下,我只会使用2个独立的子模块来构建适当的战争。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.