解决Maven本地库中存在依赖但还是报错找不到

在使用maven打包执行package的过程中,在下载依赖包的这一步报错:

Failure to find org.pentaho:pentaho-aggdesigner-algorithm:pom:5.1.5-jhyde in https://repository.cloudera.com/artifactory/cloudera-repos/ was cached in the local repository, resolution will not be reattempted until the update interval of cloudera has elapsed or updates are forced

解决Maven本地库中存在依赖但还是报错找不到_第1张图片
但是事实上这个包在本地库中已经存在了:解决Maven本地库中存在依赖但还是报错找不到_第2张图片
百思不得其解,偶然间尝试打开“_remote.repositories”文件如下:

#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Wed Jan 08 11:35:56 CST 2020
pentaho-aggdesigner-algorithm-5.1.5-jhyde.pom>conjars=
pentaho-aggdesigner-algorithm-5.1.5-jhyde.jar>conjars=

对比正常可以使用的包中的该文件:

#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Fri Aug 10 10:04:28 CST 2018
spring-boot-starter-web-1.5.9.RELEASE.pom>central=
spring-boot-starter-web-1.5.9.RELEASE.jar>central=
spring-boot-starter-web-1.5.9.RELEASE.pom>alimaven=
spring-boot-starter-web-1.5.9.RELEASE.jar>alimaven=

这里的central、alimaven表示setting.xml中配置的私服id,只有存在该资源的镜像或私服才会将私服或镜像的id写入到_remote.repositories中。
这个文件存储的是每次从私服或者中央仓库下载的jar包的信息。

  • 第3行:pom文件>私服ID名称
  • 第4行:jar文件>私服ID名称
  • 第5、6行:从另一个私服下载的记录

然而,我的settings.xml连不上>conjars这个私服。因此,将其改为central:

#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Wed Jan 08 11:35:56 CST 2020
pentaho-aggdesigner-algorithm-5.1.5-jhyde.pom>central=
pentaho-aggdesigner-algorithm-5.1.5-jhyde.jar>central=

重新执行后成功:
解决Maven本地库中存在依赖但还是报错找不到_第3张图片
总结:

假设我们更换了私服地址为nexus-abc,并且该私服不存在所依赖的资源,那么就会生成xxx.lastUpdated文件;
依赖包的_remote.repositories文件用来标示该资源的来源,如果你有这个_remote.repositories,那就会在访问本地的同时,必须确保远程上有才行(这里的远程指的是settings.xml文件中配置的镜像或远程仓库,通过mirror标签的id来进行关联),否则就会报错。

参考:

关于maven仓库中的_remote.repositories
_remote.repositories文件的作用/Maven修改setting文件后本地仓库缓存了jar或pom但还是去远程仓库获取

你可能感兴趣的:(Maven)