maven探究四:在maven中配置nexus作为私服仓库

    让maven项目使用nexus作为远程仓库有两种方式,第一种是在项目的pom.xml中进行更改,让单个项目使用nexus仓库;另一种是通过修改maven的配置文件settings.xml进行更改,让所有项目都使用nexus仓库。第一种方式需要针对每个项目都进行配置,较为繁琐。故建议选择第二种配置方式,一次性到位。

进入maven安装目录的conf文件夹打开,修改settings.xml文件。


<profile>
	<id>nexusprofile</id>
	<repositories>
        <repository>
		<id>nexus</id>
		<name>nexus repository</name>
		<url>http://192.168.x.x:8181/nexus/content/groups/public/</url>
		<releases>
			<enabled>true</enabled>
		</releases>
		<snapshots>
			<enabled>true</enabled>
		</snapshots>
        </repository>
      </repositories>
   </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexusprofile</activeProfile>
  </activeProfiles>
注意: <activeProfile>标签的目的是激活上面的profile配置功能,一定要加上。 而且标签中的内容一定要和profile当中的id保持一致。

配置成功后,maven工程在下载依赖的时候,会自动从nexus私服当中下载,如果nexus当中没有,则nexus会自动从maven中央仓库下载,并缓存在nexus当中。


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值