在使用maven构建项目的war包时,有时并不需要src/webapp/WEB-INF/下的一些文件。

这时可以通过maven-war-plugin创建配置来排除这些文件。下面贴出我平时使用的pom.xml文件

配置信息在 project -> build -> plugins -> plugin -> maven-war-plugin

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xank</groupId>
    <artifactId>zheng</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>

    <name>security Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <finalName>zheng</finalName>
    </properties>

    <repositories>
        <repository>
            <id>nexus</id>
            <name>MZONE</name>
            <url>http://www.xank.com.cn/nexus/content/groups/public/</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <!-- 设置war包名称 -->
        <finalName>/${finalName}</finalName>
        <resources>
            <!-- 包含hbm.xml(或者将xhm.xml放到resource中) -->
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.hbm.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                    <include>**/*.txt</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <!-- web 目录 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <webResources>
                        <resource>
                            <excludes>
                                <exclude>**/WEB-INF/web.xml</exclude>
                            </excludes>
                            <directory>src/webapp</directory>
                        </resource>
                    </webResources>
                   <failOnMissingWebXml>false</failOnMissingWebXml>
            <!-- 下面两个配置没有生效,这里贴出是表示提醒 <packagingExcludes>src/webapp/WEB-INF/web.xml</packagingExcludes> <warSourceExcludes>src/webapp/WEB-INF/web.xml</warSourceExcludes> --> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/${project.artifactId}</path> <url>http://127.0.0.1:8081/manager/text</url> <server>tomcat7</server> <username>admin</username> <password>admin</password> </configuration> </plugin> </plugins> </build> <profiles> <profile> <!-- 快速部署 (结合部署脚本使用) --> <id>deploy</id> <properties> <finalName>security</finalName> </properties> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <phase>compile</phase> <configuration> <target> <copy todir="${basedir}/target/classes/" overwrite="true"> <fileset dir="${basedir}/release/deploy/resources/" /> </copy> <!-- 目的路径不能写成 ${basedir}src/webapp/WEB-INF/ 会造成文件修改 --> <copy todir="${basedir}/target/${project.artifactId}/WEB-INF/" overwrite="true"> <fileset dir="${basedir}/release/deploy/WEB-INF/" /> </copy> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> </project>

【Maven】构建war包时排除web.xml的更多相关文章

  1. maven 构建war包时排除web.xml

    在使用maven构建项目的war包时,有时并不需要src/webapp/WEB-INF/下的一些文件. 这时可以通过maven-war-plugin创建配置来排除这些文件.下面贴出我平时使用的pom. ...

  2. Maven打war包时,添加本地jar包

    1.在项目根目录中新建lib文件夹,添加jar包 2.在pom.xml文件中添加dependency <dependency> <groupId>com.oracle</ ...

  3. 自动构建War包的Ant build.xml模板

    <?xml version="1.0" encoding="UTF-8" ?> <project name="[*****]你的项目 ...

  4. maven打war包后无法依赖本地工程的jar包,造成debug时跳到class文件而不是本地java文件

    问题现象:项目结构如下 growup-service | - - - - - -growup-api | - - - - - -growup-core | - - - - - -growup-war ...

  5. maven生成war包的两种方式

    war包即对WEB应用程序进行打包,用于应用容器的部署.如在jboss中只要把war包丢入deploy目录下即可发布自己的应用了.打包方式有很多中,很多工具本身就支持此功能.下面主要介绍通过maven ...

  6. IDEA多模块父子依赖maven项目war包部署

    IDEA多模块父子依赖maven项目war包部署 Posted on 2018-04-25 | In IDEA | | Visitors 286 IDEA全称为IntrlliJ IDEA,它是一款非常 ...

  7. Maven开发基础总结(Maven自启动,Maven打war包,Maven热部署)

    学习内容: 1.不依赖外部Tomcat,自己启动方式部署 2.Maven打war包,远程部署到centOS 3.Maven热部署(不关闭Tomcat部署应用)   做maven开发前提: 1.编码UT ...

  8. 告诉maven,我真的不需要web.xml

    <!-- 告诉maven,我真的不需要web.xml --> <plugin> <groupId>org.apache.maven.plugins</grou ...

  9. 配置ssm 时, web.xml 文件无 # 自动代码提示

    环境:STS 版本:spring-tool-suite-3.8.1.RELEASE-e4.6-win32-x86_64 配置ssm 时, web.xml 文件无 如下图蓝色圈范围内的提示 问题与 链接 ...

随机推荐

  1. Win8.1下VM与Hyper-v冲突解决方法

    不需要使用hyperv.去程序那里关闭hyperv.要同时使用两中虚拟机.使用折中的办法:  创建两个启动菜单,在启动的时候选择是否要运行 Hyper-V. 管理员身份运行命令提示符 cmd 输入 b ...

  2. Python爬虫从入门到放弃(十七)之 Scrapy框架中Download Middleware用法

    这篇文章中写了常用的下载中间件的用法和例子.Downloader Middleware处理的过程主要在调度器发送requests请求的时候以及网页将response结果返回给spiders的时候,所以 ...

  3. request.setcharacterencoding()和request.setcontenttype

    1.request.setCharacterEncoding()是设置从request中取得的值或从数据库中取出的值 指定后可以通过getParameter()则直接获得正确的字符串,如果不指定,则默 ...

  4. 还在为画“类Word文档报表”而发愁吗?

    欢迎大家持续关注葡萄城控件技术团队博客,更多更好的原创文章尽在这里~~​ Word 是非常强大的文档编辑工具,一些行业制式文档都是使用Word来创建的,像教育行业的申请表,履历表,审批表等,像石油业的 ...

  5. 树状数组(瞎bb) [树状数组]

    Copyright:http://www.cnblogs.com/ZYBGMZL/ 树状数组是一个利用一维数组和位运算组成的求解区间问题的高效数据结构,其构造如图所示 首先,我们要用它解决单点修改.区 ...

  6. 【Splay】例题

    营业额统计 题目背景 HNOI2002 DAY2 T2 题目描述 Tiger 最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况. Tiger 拿出了公司 ...

  7. Exception in thread "http-bio-8080-exec-2" java.lang.OutOfMemoryError: PermGen space[解决方案]

  8. HDU 6035---Colorful Tree(树形DP)

    题目链接 Problem Description There is a tree with n nodes, each of which has a type of color represented ...

  9. ubuntu解压乱码

    乱码原因 问题一般出现在windows下压缩的在ubuntu中会出现这种情况. 其实就是windows和ubuntu下压缩的编码格式不同.windows下的编码格式为GBK,Ubuntu下的为UTF- ...

  10. pick定理详解

    一.概念 假设P的内部有I(P)个格点,边界上有B(P)个格点,则P的面积A(P)为:A(P)=I(P)+B(P)/2-1. 二.说明 Pick定理主要是计算格点多边形(定点全是格点的不自交图形)P的 ...