maven库

在Maven构建项目的过程中如果需要某些构件,首先会到Maven的本地仓库中查找,如果找到则可以直接使用;如果找不到,它会自动连接外网,到远程中央仓库中查找;如果远程仓库中能找到,则先把所需要的插件下载到本地仓库,然后再使用,并且下次再用到相同的插件就可以直接使用本地仓库的;如果没有外网或者远程仓库中也找不到,则构建失败。

1.使用profile配置远程仓库

在settings.xml中

 <profiles>
    
	<profile>
		   <id>dev</id>
		   <repositories>  
			<repository>
			  <id>nexus-aliyun</id>
			  <name>Nexus aliyun</name>
			  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
			  <layout>default</layout>
			  <snapshots>
				<enabled>false</enabled>
			  </snapshots>
			</repository>
		   </repositories>
		   <pluginRepositories>
			<pluginRepository>
			 <id>nexus-aliyun</id>
			  <name>Nexus aliyun</name>
			  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
			  <layout>default</layout>
			  <snapshots>
				<enabled>false</enabled>
			  </snapshots>
			  <releases>
				<updatePolicy>never</updatePolicy>
			  </releases>
			</pluginRepository>
		  </pluginRepositories>
	</profile>
	
  </profiles>

<activeProfiles>
    <activeProfile>dev</activeProfile>
  </activeProfiles>

2.覆盖远程库

所有的POM都使用唯一的一个远程库,可以使用settings.xml中的mirror配置。

<mirror>
    <!--This sends everything else to /public -->
    <id>nexus-aliyun</id>
    <mirrorOf>*</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

注意:如果你想覆盖指定的远程创库那么你只需要改变id就可以了
比如你想覆盖中央库中央库的在这里插入图片描述
id为central修改mirrorOf即可

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值