maven插件maven-war-plugin的使用

原创
2015/08/06 14:38
阅读数 2.3W

  •     在plugins下添加以下代码

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <warName>${project.artifactId}</warName>
        <warSourceExcludes>nodejs/**</warSourceExcludes>
        <webResources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/profile</directory>
                <targetPath>WEB-INF</targetPath>
                <includes>
                    <include>**/web.xml</include>
                </includes>
            </resource>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/profile/pages</directory>
                <targetPath>pages</targetPath>
                <includes>
                    <include>**</include>
                </includes>
            </resource>
        </webResources>
        <warSourceDirectory>src/main/webapp</warSourceDirectory>
        <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
    </configuration>
</plugin>

  • src/main/profile的目录结构与打包后war的目录结构一致

    • targetPath即要替换的目录,include为要替换的文件

    • 上面的代码会将src/main/profile替换WEB-INF下的web.xml,已经pages下的文件

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部