Nexus和Maven集成的两种方式

 Nexus安装配置完成后,需要在Maven中进行相应的配置才能正常使用,配置方式主要有两种:

 

方式1.在~/.m2/setting.xml文件(或者&M2_HOME/conf/settings.xml文件)中配置镜像,如:

 

		<mirror>  
			<id>nexus</id>  
			<mirrorOf>central</mirrorOf>  
			<name>Public Repositories</name>  
			<url>http://127.0.0.1:9002/nexus/content/groups/public</url>   
		</mirror>
 

 

方式2:在项目的pom.xml文件中配置仓库地址,如:

 

      <repositories>  
		<repository>   
			<id>public</id>  
			<name>Public Repositories</name>  
			<url>http://localhost:9002/nexus/content/repositories/central</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>  
		</repository>  
	</repositories>
	<pluginRepositories>  
		<pluginRepository>  
			<id>public</id>  
			<name>Public Repositories</name>  
			<url>http://localhost:9002/nexus/content/repositories/central</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>  
		</pluginRepository>  
	</pluginRepositories>

 

     很显然,使用方式2需要在所有项目的pom.xml文件中进行配置,造成了重复,如果同时使用方式1和方式2进行了配置,那么Maven会优先使用settings.xml文件中的镜像地址进行查找.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值