首页 > 其他 > 详细

maven 配置自动本地/线上不同配置自动打包

时间:2018-02-09 19:14:55      阅读:196      评论:0      收藏:0      [点我收藏+]

工程结构:在resource下新建开发,线上不同文件夹存放不同配置文件

技术分享图片

pom.xml配置文件

<!-- maven配置不同环境打包 -->
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>${project.artifactId}</warName>
<webResources>
<resource>
<directory>src/main/resources/${package.environment}</directory>
<targetPath>WEB-INF/classes</targetPath>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>dev</id>
<properties>
<package.environment>dev</package.environment>
</properties>
<activation>
<!-- 默认使用开发环境 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>prod</id>
<properties>
<package.environment>prod</package.environment>
</properties>
</profile>
</profiles>
<!-- maven配置不同环境打包 -->

具体意思可学习maven相关知识

 package -P prod 线上编译打包
 package -P dev本地调试
 

maven 配置自动本地/线上不同配置自动打包

原文:https://www.cnblogs.com/coderdxj/p/8436027.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!