使用profile解决maven不同的环境deploy到不同的repositories

一:修改apache-maven-3.3.9\conf\settings.xml 在profiles标签中,添加如下profile

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <!-- 开发环境 (snapshots环境) --></span>  
  2. <profile>  
  3.     <id>dev</id>  
  4.     <properties>  
  5.         <repository.id>dev</repository.id>  
  6.         <repository.name>Dev Repository</repository.name>  
  7.         <repository.url>http://admin:123456@192.168.1.101/content/repositories/snapshots/</repository.url>  
  8.     </properties>  
  9. </profile>  
  10.   
  11. <!-- 正式环境(releases环境) --></span>  
  12. <profile>  
  13.     <id>production</id>  
  14.     <properties>  
  15.         <repository.id>production</repository.id>  
  16.         <repository.name>Production Repository</repository.name>  
  17.         <repository.url>http://admin:123456@192.168.1.101/content/repositories/releases/</repository.url>  
  18.     </properties>  
  19. </profile>  


以上的admin/123456为仓库的用户名/密码,请自行修改


[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <!-- 默认启用dev环境 -->  
  2. <activeProfiles>  
  3.     <activeProfile>dev</activeProfile>  
  4. </activeProfiles>  

二:

在项目的pom.xml里面添加

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <distributionManagement>  
  2.     <repository>  
  3.         <id>${repository.id}</id>  
  4.         <name>${repository.name}</name>  
  5.         <url>${repository.url}</url>  
  6.         <layout>default</layout>  
  7.     </repository>  
  8. </distributionManagement>  

三:deploy

mvn clean deploy -Pproduction 表示deploy到正式环境

mvn clean deploy 或者 mvn clean deploy -Pdev 表示deploy到开发环境

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值