Nexus私服上有包却无法下载Could not find artifact

文章讲述了在学习Nexus过程中遇到的项目报错问题,即无法从Nexus下载jar包。问题出在maven配置上,不是<mirror>标签的问题,而是需要在settings.xml中配置<servers>和<profiles>,包括仓库的URL、用户名和密码,以及启用release和snapshot版本下载。通过正确配置,可以成功从私有仓库下载依赖。

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

问题描述

我是在学习Nexus过程当中产生的该问题,然后Nexus是安装在了本地电脑。

项目报错如下:

在这里插入图片描述

maven配置的也没毛病呀

在这里插入图片描述

nexus当中也的确有该jar包呀,这就奇怪了。

在这里插入图片描述

问题解决

其实是配置有问题的,网上很多教程都是让你在maven当中配置<mirror>标签,实际上配置他根本就不行。在maven的setting.xml配置如下配置即可下载:

<servers>
  <!-- 这是配置访问私有仓库的用户名密码 -->
  <server>
    <!-- id标签可以随便填,只需要在servers中唯一即可,后面很多地方会使用该id -->
    <id>self-maven</id>
    <username>deplyment</username>
    <password>deplyment123</password>
  </server>
</servers>
<profiles>
	<profile>
        <id>nexus</id>
        <!--声明一个或多个远程仓库  -->
		<repositories>
			<!-- 声明一个 Nexus 私服上的仓库  -->
			<repository>
				<!--仓库id,这个id就是上面配置的账号密码id  -->
				<id>self-maven</id>
				<!-- 仓库的名称 -->
				<name>nexus</name>
				<!--仓库的地址  -->
				<url>http://localhost:8081/repository/maven-public/</url>
				<!-- 是否开启该仓库的 release 版本下载支持 -->
				<releases>
					<enabled>true</enabled>
				</releases>
				<!-- 是否开启该仓库的 snapshot 版本下载支持 -->
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</repository>
		</repositories>
		<!-- 声明一个或多个远程插件仓库 -->
		<pluginRepositories>
			<!--声明一个 Nexus 私服上的插件仓库  -->
			<pluginRepository>
				<!--插件仓库 id -->
				<id>self-maven</id>
				<!--插件仓库 名称 -->
				<name>nexus</name>
				<!-- 配置的插件仓库的地址 -->
				<url>http://localhost:8081/repository/maven-public/</url>
				<!-- 是否开启该插件仓库的 release 版本下载支持 -->
				<releases>
					<enabled>true</enabled>
				</releases>
				<!-- 是否开启该插件仓库的 snapshot 版本下载支持 -->
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</pluginRepository>
		</pluginRepositories>
          <properties>
              <maven.compiler.source>1.8</maven.compiler.source>
              <maven.compiler.target>1.8</maven.compiler.target>
              <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
          </properties>
	<!-- 默认该profile生效 -->
          <activation>
              <activeByDefault>true</activeByDefault>
          </activation>
      </profile>
</profiles>       
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

怪 咖@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值