maven 构建war包时排除web.xml
在使用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的更多相关文章
- 【Maven】构建war包时排除web.xml
在使用maven构建项目的war包时,有时并不需要src/webapp/WEB-INF/下的一些文件. 这时可以通过maven-war-plugin创建配置来排除这些文件.下面贴出我平时使用的pom. ...
- Maven打war包时,添加本地jar包
1.在项目根目录中新建lib文件夹,添加jar包 2.在pom.xml文件中添加dependency <dependency> <groupId>com.oracle</ ...
- 自动构建War包的Ant build.xml模板
<?xml version="1.0" encoding="UTF-8" ?> <project name="[*****]你的项目 ...
- maven打war包后无法依赖本地工程的jar包,造成debug时跳到class文件而不是本地java文件
问题现象:项目结构如下 growup-service | - - - - - -growup-api | - - - - - -growup-core | - - - - - -growup-war ...
- maven生成war包的两种方式
war包即对WEB应用程序进行打包,用于应用容器的部署.如在jboss中只要把war包丢入deploy目录下即可发布自己的应用了.打包方式有很多中,很多工具本身就支持此功能.下面主要介绍通过maven ...
- IDEA多模块父子依赖maven项目war包部署
IDEA多模块父子依赖maven项目war包部署 Posted on 2018-04-25 | In IDEA | | Visitors 286 IDEA全称为IntrlliJ IDEA,它是一款非常 ...
- Maven开发基础总结(Maven自启动,Maven打war包,Maven热部署)
学习内容: 1.不依赖外部Tomcat,自己启动方式部署 2.Maven打war包,远程部署到centOS 3.Maven热部署(不关闭Tomcat部署应用) 做maven开发前提: 1.编码UT ...
- 告诉maven,我真的不需要web.xml
<!-- 告诉maven,我真的不需要web.xml --> <plugin> <groupId>org.apache.maven.plugins</grou ...
- 配置ssm 时, web.xml 文件无 # 自动代码提示
环境:STS 版本:spring-tool-suite-3.8.1.RELEASE-e4.6-win32-x86_64 配置ssm 时, web.xml 文件无 如下图蓝色圈范围内的提示 问题与 链接 ...
随机推荐
- 怎样用QtCreator编辑运行python脚本
QtCreator作为一款开发基于qt库的程序.以及开发C语言.c++语言项目都是一个利器,轻便好用.那么作为开发者来说,经常换着使用各种IDE是家常便饭,但是要是这些语言都能够集成到一个工具里岂不是 ...
- 【第十九章】 springboot + hystrix(1)
hystrix是微服务中用于做熔断.降级的工具. 作用:防止因为一个服务的调用失败.调用延时导致多个请求的阻塞以及多个请求的调用失败. 1.pom.xml(引入hystrix-core包) 1 < ...
- Linux 安装 mysql 转 http://www.cnblogs.com/fnlingnzb-learner/p/5830622.html
到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (g ...
- JavaScript权威指南2.词法结构
字符集 1.用16位的Unicode字符集编写的,可以表示地球上通用的每一种书面语言.国际化 2.每个字符都是用两个字节表示的 3.大小写敏感:关键字.变量.函数名.标识符:HTML并不区分大小写 H ...
- c++ 算法 栅格中两点之间连线
屏幕划线,通过平面坐标系实现,基本组成是一个一个的点,起点为A,终点为B 本文的算法,可以实现平面栅格中,指定的A,B两点之间进行连线(代码中仅打印了两点间需要画出的坐标点) #include < ...
- STL_算法_01_查找算法
1. 来自教程:第6讲 PPT.15 ◆ 常用的查找算法: 1.1.按条件查找N个相邻的元素 ( adjacent 是 邻近的意思) iterator = adjacent_find(iterator ...
- Spring生态顶级项目说明
1.Spring IO platform 说明:用于系统部署,是可集成的,构建现代化应用的版本平台 2.Spring Boot 说明:旨在简化创建产品级的 Spring 应用和服务,简化了配置文件,使 ...
- webpack 集成 jQuery 和 Avalon
webpack 系列 三:webpack 如何集成第三方js库 webpack系列目录 webpack 系列 一:模块系统的演进 webpack 系列 二:webpack 介绍&安装 webp ...
- js插件---Bootstrap 树控件
js插件---Bootstrap 树控件 一.总结 一句话总结:可以直接用gojs,或者搜索js,jquery的树控件,或者bootstrap树控件,一大堆 gojs 二.JS组件系列——Bootst ...
- 20170813pptVBA批量插入图片
Sub AddSldIn() Dim Pre As Presentation Dim NewSld As Slide Set Pre = Application.ActivePresentation ...