栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Maven:自定义Web应用程序项目的web.xml

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Maven:自定义Web应用程序项目的web.xml

有没有办法拥有两个web.xml文件并根据配置文件选择适当的文件?

是的,您可以在每个配置文件中添加的配置,

maven-war-plugin
并将每个配置配置为指向不同的
web.xml

<profiles>    <profile>        <id>profile1</id>        <build> <plugins>     <plugin>         <groupId>org.apache.maven.plugins</groupId>         <artifactId>maven-war-plugin</artifactId>         <configuration>  <webXml>/path/to/webXml1</webXml>         </configuration>     </plugin>      ...

作为不必

maven-war-plugin
在每个概要文件中指定配置的替代方法,可以在POM的主要部分中提供默认配置,然后仅对特定概要文件覆盖它。

或更简单地说,在

<build><plugins>
您的POM 主体中,使用属性来引用
webXml
属性,然后在不同的配置文件中更改其值

<properties>    <webXmlPath>path/to/default/webXml</webXmlPath></properties><profiles>    <profile>        <id>profile1</id>        <properties> <webXmlPath>path/to/custom/webXml</webXmlPath>        </properties>    </profile></profiles><build>    <plugins>        <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration>     <webXml>${webXmlPath}</webXml> </configuration>        </plugin>        ...


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/595264.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号