阿里巴巴私服nexus使用

本文介绍了解决Maven项目中jar包下载失败的问题方法。通过配置Maven私服(如阿里巴巴Nexus),确保所有依赖包都能成功下载。文章详细说明了在setting.xml和pom.xml中如何添加私服仓库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚学maven不久,今天在搭建maven项目的时候,碰到了好多jar包下载错误的问题,后来配置了maven私服仓库,成功的解决了问题。原因是maven从自己默认提供的中央仓库中下载时部分jar包因为未知原因无法下载。所以从第三方仓库(阿里巴巴私服nexus)下载是一个很好的选择。

1、在maven安装目录下conf里面的setting.xml(配置文件里面添加一段代码)

<mirrors>
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
  </mirrors>
注意:因为原文件中有一个空的<mirrors></mirrors>标签,所以直接添加会出现重复标签错误,所以要先找的原来的标签加以修改即可。

2、在maven工程的pom.xml文件中加入如下代码:

 <repositories>
        <repository>
            <id>nexus-aliyun</id>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <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>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

完成后重新build项目,即可下载所有的jar包。若有其他错误,另寻解决方法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值