pom.xml配置,针对mvn clean install -P参数(环境参数)打包
pom.xml配置,针对mvn clean install -P参数(环境参数)打包
比如你有2个环境,一个dev,一个prod,
然后你在mvn打包的时候,可以通过-P来打包,是打dev包,还是prod包。
pom.xml可以这样配置
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault> //如果不带-P但是,默认是dev
</activation>
</profile>
<profile>
<id>devtest</id>
<properties>
<env>devtest</env>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>
-Pdev / -Pprod 的参数dev/prod,会根据传入的参数代入到具体的打包配置中
<build>
<finalName>xzair-rest</finalName>
<scriptSourceDirectory>src/main/java</scriptSourceDirectory>
<resources>
<resource>
<directory>src/main/resources/${env}</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>dev/*</exclude>
<exclude>devtest/*</exclude>
<exclude>prod/*</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/java</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/resources/${env}</directory>
<targetPath>WEB-INF/classes</targetPath>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>dev/*</exclude>
<exclude>devtest/*</exclude>
<exclude>prod/*</exclude>
</excludes>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
<filtering>false</filtering>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<!-- 过滤后缀为pem、pfx的证书文件 -->
<nonFilteredFileExtensions>
<nonFilteredFileExtension>pem</nonFilteredFileExtension>
<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
<nonFilteredFileExtension>p12</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/xzair-rest</path>
<charset>${project.build.sourceEncoding}</charset>
<port>${server.port}</port>
<uriEncoding>${project.build.sourceEncoding}</uriEncoding>
</configuration>
</plugin>
</plugins>
</build>
cmd打包的时候可以这样打
mvn clean isntall -Pprod
或者
mvn clean install -Pdev
pom.xml配置,针对mvn clean install -P参数(环境参数)打包的更多相关文章
- 学习笔记——Maven pom.xml配置详解
POM的全称是“ProjectObjectModel(项目对象模型)”. pom.xml详解 声明规范 <projectxmlns="http://maven.apache.org/P ...
- Maven使用笔记(四)pom.xml配置详解
pom.xml文件配置详解 --声明规范 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=" ...
- (转)mvn clean install 与 mvn install 的区别(为啥用clean)
之前写代码的过程中曾经遇到过问题,用mvn install后,新改的内容不生效,一定要后来使用mvn clean install 才生效,由于之前没有做记录,以及记不清是什么情况下才会出现的问题,于是 ...
- Maven pom.xml配置详解
POM的全称是“ProjectObjectModel(项目对象模型)”. 声明规范 <projectxmlns="http://maven.apache.org/POM/4.0.0&q ...
- 【转】Maven pom.xml 配置详解
原文链接:https://yq.aliyun.com/articles/38271 pom.xml文件配置详解 --声明规范 <project xmlns="http://maven. ...
- Eclipse编译运行没问题,但执行mvn clean install跑单元测试失败的原因解析
问题描述:mvn clean install编译工程并运行单元测试出现如下错误 Tests run: 3, Failures: 0, Errors: 2, Skipped: 0, Time elaps ...
- Maven命令行使用:mvn clean install(安装)
先把命令行切换到Maven项目的根目录,比如:/d/xxxwork/java/maven-test,然后执行命令: $ mvn clean install 执行结果如下: [INFO] Scannin ...
- 如何在eclipse中使用mvn clean install
1.在Maven项目或者pom.xml上右键——>Run As ——>“Maven Build...”或者Run Configuration——>“Maven Build” 2.在“ ...
- spring boot(14)-pom.xml配置
继承spring-boot-starter-parent 要成为一个spring boot项目,首先就必须在pom.xml中继承spring-boot-starter-parent,同时指定其版本 & ...
随机推荐
- PHP 十万数字不同数组取最大的5个 (经典面试题topK) (原)
$arr = array(3,5,7,8,1,2,456,78,...101,2345,456); 类似上述数组,共有十万个元素,让我们取出TOP5,下面是我的解法,先上代码再讲解思路 functio ...
- mysql----------原生的sql里面如何根据case then排序
1.按照三个字段都符合条件来排序 ORDER BY ( CASE WHEN is_top = 1 AND top_end_time>UNIX_TIMESTAMP() AN ...
- Kali-Dos洪水攻击之Hping3
在计算机行业,拒绝服务(DoS)或分布式拒绝服务(DDoS)攻击是指不法分子企图让某机器或网络资源无法被预期的用户所使用.虽然执行DoS攻击的方式.动机和目标不一样,但通常包括设法临时性或无限期中断或 ...
- spring boot+spring data jpa+gradle+mysql配置问题
1.gradle/wrapper/gradle-wrapper里要设置正确本地的gradle目录(我用的是4) 2.在src目录里的application.properties文件里,可以这样设置 # ...
- Python爬虫与一汽项目【三】爬取中国五矿集团采购平台
网站地址:http://ec.mcc.com.cn/b2b/web/two/indexinfoAction.do?actionType=showMoreCgxx&xxposition=cgxx ...
- python numpy 科学计算通用函数汇总
import numpy as np #一元函数 #绝对值计算 a = -1b = abs(a)print(b)输出: 1 #开平方计算 a = 4b = np.sqrt(a)print(b)输出: ...
- Qt重绘之update,repaint详解
Qt里面的重绘和Windows编程里面的重绘差不多.但是Qt的重绘更有特色,更加智能. 在讲之前,先说说paintEvent() paintEvent()是一个虚函数槽(slot),子类可以对父类的p ...
- 2、Storm中的一些概念理解
1.Tuple,Value,Field Tuple官方解释: "A tuple is a named of values where each value can be any type.& ...
- 【MySQL】InnoDB 内存管理机制 --- Buffer Pool
InnoDB Buffer Pool 是一块连续的内存,用来存储访问过的数据页面 innodb_buffer_pool_size 参数用来定义 innodb 的 buffer pool 的大小 是 M ...
- elasticsearch+logstash_jdbc 实现mysql数据实时同步至es
jdk安装1.8版本,es.ls.ik.kibana版本一致我这里使用的6.6.2版本 安装es tar xf elasticsearch-6.6.2.tar.gz mv elasticsearch- ...