目录
一、问题描述
背景:做 Spark 项目时,需要添加 hive-exec 依赖,其中引用了 5.1.5-jhyde 包,但已配置的远程仓库中不包含此包无法下载,因此加载时出现报错信息。
报错信息:Could not find artifact org.pentaho:pentaho-aggdesigner-algorithm:pom:5.1.5-jhyde in nexus (...)。表示Maven配置的远程仓库链接无法下载到此包。
二、解决方案
1、依赖
添加 hive-exec 依赖时,其中有引用 org.pentaho:pentaho-aggdesigner-algorithm:5.1.5-jhyde 的包。 注释部分依赖是否添加都无所谓,此处用作测试是否能够下载依赖包。
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>2.1.1</version>
</dependency>
<!--
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
<version>5.1.5-jhyde</version>
</dependency>
-->
2、settings.xml 配置文件
注意仓库顺序!!!
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>spring-plugin</name>
<url>https://maven.aliyun.com/repository/spring-plugin</url>
</mirror>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*,!cloudera</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
3、重启IDEA
File -》Invalidate Caches -》Invalidate and Restart
三、解决过程
尝试一:刚开始,我以为是本地文件夹 .lastUpdated 文件的问题导致的缓存无法下载,所以清空了本地仓库中的 .lastUpdated 文件。刷新IDEA工具 Maven 依赖列表再次加载依赖。还是出现 Problems 报错信息:Could not find artifact org.pentaho:pentaho-aggdesigner-algorithm:pom:5.1.5-jhyde in nexus ...
尝试二:根据报错信息,确实是配置的远程仓库中没有此包,于是去Maven的镜像仓库中手动找包,自行下载下来放到对应的目录中,这里附上下载链接: Nexus Repository Manager 。我将整个文件夹中的文件都下载下来放到了本地仓库中对应的目录下,再次重启IDEA,还是报同样的错误:Could not find artifact org.pentaho:pentaho-aggdesigner-algorithm:pom:5.1.5-jhyde in nexus ...
尝试三:通过上网搜索解决方案,发现有前辈通过添加多个仓库的方式解决的此类问题,于是我也照葫芦画瓢,在我本来的仓库配置后面,添加了阿里云的两个仓库, 但!!依旧报错!!!!
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*,!cloudera</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>spring-plugin</name>
<url>https://maven.aliyun.com/repository/spring-plugin</url>
</mirror>
<mirror>
<id>repo2</id>
<name>Mirror from Maven Repo2</name>
<url>https://repo.spring.io/plugins-release/</url>
<mirrorOf>central</mirrorOf>
</mirror>
尝试四:很少遇到这种尝试了各种方法都没解决的依赖问题,太久没操作,对仓库配置不熟悉,怀疑可以配置多个仓库么?会引起仓库检索的问题么?不然没地方下手了。于是一次又一次的调整 mirror 配置个数、顺序,试了很久重启了IDEA很多次,终于没有报错成功下载了jar包!!!!
方法就在解决方案那里,自行拿取❤❤❤。