[英]How to replace web.xml during build with Maven?
我和maven有问题。 我正在使用tomcat7-maven-plugin将我的战争部署到一个tomcat中并且效果很好。
但是现在我想将文件更改为生成的war之前将其发送到servlet容器。 可能吗? 特别是我想用另一个更改默认的web.xml。
我已经尝试过maven-resources-plugin,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.2</version>
<executions>
<execution>
<id>default-copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${project.build.directory}/${project.artifactId}/WEB-INF/</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/webapp/ext/WEB-INF</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
但是这个插件只替换目标WEB-INF文件夹中的web.xml,没有任何东西会被改成war文件。 有人可以帮我找到合适的插件来实现我的目的吗?
更新:
我决定使用它: https : //stackoverflow.com/a/3298876/2148530
您可以在其中定义您的配置文件(在您的pom.xml中),覆盖maven.war.webxml属性:
<properties>
<maven.war.webxml>path/to/your/custom/web.xml</maven.war.webxml>
</properties>
解决方案(不是我的),取自Maven:使用Maven War Plugin和webXml
参数自定义web-app项目的web.xml 。
webXml要使用的web.xml文件的路径。
<profiles>
<profile>
<id>tomcat</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${project.basedir}/src/main/webapp/ext/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.