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

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

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>        ...


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5586456.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-14
下一篇2022-12-15

发表评论

登录后才能评论

评论列表(0条)

    保存