maven Nexus的一些注意事项

本文解决Maven构建错误中构件下载失败的问题,分析了Nexus配置中的PublicRepositories顺序错误导致构件无法下载的原因,并给出了正确的配置顺序。同时介绍了如何为Nexus设置代理以确保可以从Maven Repository中心成功下载构件。

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

一、发现配置后,下载构件抛异常。

0-10-3 下午05时09分43秒: Build error for /com.newyulong.iptv.domain.entity/pom.xml; org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.1 or one of its dependencies could not be resolved: Missing:
----------
1) org.apache.maven.plugins:maven-resources-plugin:maven-plugin:2.4.1

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.apache.maven.plugins -DartifactId=maven-resources-plugin -Dversion=2.4.1 -Dpackaging=maven-plugin -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.apache.maven.plugins -DartifactId=maven-resources-plugin -Dversion=2.4.1 -Dpackaging=maven-plugin -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

----------
1 required artifact is missing.

for artifact: 
  org.apache.maven.plugins:maven-resources-plugin:maven-plugin:2.4.1

from the specified remote repositories:
  Nexus (http://localhost:8181/nexus/content/groups/public , releases=true, snapshots=false)

 

二、主要原因是配置nexus里面的 Public Repositories 顺序和条件出错,导致不能下载构件。

 

这个是正确的配置顺序,左边的是正在使用的定义好的仓库组,一边是可选的。下载构件的顺序是先在本地releases找有没有,再snapshots,再3rd party,最后是本地机子都没有构件就到远程(外网)提供的网站下载构件。

 

 

好多公司处于安全考虑,用代理上网,而nexus 经常需要往maven repository中心下载东西,所以需要给nexus设置代理。 开始没找到地方,后来发现可以从nexus后台管理器界面上直接设置,地方很隐蔽: 

登陆后进入管理页面,从左边菜单栏选择Server 打开右边tab页,发现还是找不到,别着急,仔细找会发现有行: default http proxy settings   前面有个checkbox 未勾选, 速度勾选之,马上出现了您熟悉的  proxy host,proxy port , username , passowrd.  okay 代理设置完成,现在nexus能通过互联网从maven repository中心下载东西了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值