【Maven】构建war包时排除web.xml
来源:互联网 发布:闪电侠制造了人工智能 编辑:程序博客网 时间:2024/06/04 17:44
在使用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>
阅读全文
0 0
- 【Maven】构建war包时排除web.xml
- maven打war包排除文件目录
- maven 构建web项目时war名称由什么决定
- maven构建war包之间依赖
- maven eclipse web项目 && 打war包
- maven web 工程生成war包
- Maven 插件maven-war-plugin 构建war包,包含jks,p12证书时的踩坑记录
- maven打war包遇到缺少web.xml错误的解决方法,指定目录
- eclipse web项目用maven打war包丢失.xml文件,丢失.properties文件
- 创建maven web项目pom.xml参考代码--mvn命令打war包
- Maven -- 在进行war打包时排除不需要的文件
- maven 打war包报异常(web.xml 以及jsp js css不在war包中),以及pom.xml 文件配置
- 排除依赖包,Maven
- 构建dubbo服务消费者web应用的war包
- Maven打包无法将mapper.xml打进war包
- maven 打war包
- maven合并war包
- Maven导war包
- 随机森林的原理与实现
- JVM性能调优以及参数详解
- 【Maven】 install:install-file
- 【Git】自动化Maven项目构建脚本(一)
- 【Git】 自动化Maven项目构建脚本(二)
- 【Maven】构建war包时排除web.xml
- 【Linux】查看进程号
- 编译安装 Nginx1.12.1
- foreach遍历空集合
- 正则表达式案例篇
- 6 个技巧,提升 C++11 的 vector 性能
- hahaha终于注册了一个博客
- 编译安装 Python3.6.1
- python web入门程序