maven下载依赖失败问题及解决

 更新时间:2023年04月14日 11:08:10   作者:clooker  
这篇文章主要介绍了maven下载依赖失败问题及解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

前情提要

由于特殊原因,官方maven库经常连接失败,所以很多maven都配置了阿里云的镜像。

但是阿里云的镜像里有很多依赖都没有,这时候如果你的项目需要这些依赖,就会导致编译失败。

1. 问题1

描述

This failure was cached in the local repository and resolution is not reattempted until the update interval of aliyunmaven has elapsed or updates are forced

详细

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: windows
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: windows-x86_64
[INFO]
[INFO] -------< org.apache.pulsar:kafka-connect-avro-converter-shaded >--------
[INFO] Building Apache Pulsar :: Kafka Connect Avro Converter shaded 2.8.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.415 s
[INFO] Finished at: 2021-10-21T09:22:45+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project kafka-connect-avro-converter-shaded: Could not resolve dependencies for project org.apache.pulsar:kafka-connect-avro-converter-shaded:jar:2.8.0: Failed to collect dependencies at io.confluent:kafka-connect-avro-converter:jar:5.3.2: Failed to read artifact descriptor for io.confluent:kafka-connect-avro-converter:jar:5.3.2: io.confluent:kafka-schema-registry-parent:pom:5.3.2 was not found in https://maven.aliyun.com/repository/public during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of aliyunmaven has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

2. 问题2

描述

Could not find artifact io.confluent:kafka-connect-avro-converter:jar:5.3.2 in aliyunmaven
The POM for io.confluent:kafka-connect-avro-converter:jar:5.3.2 is missing, no dependency information available

详细

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: windows
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: windows-x86_64
[INFO]
[INFO] -------< org.apache.pulsar:kafka-connect-avro-converter-shaded >--------
[INFO] Building Apache Pulsar :: Kafka Connect Avro Converter shaded 2.8.0
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for io.confluent:kafka-connect-avro-converter:jar:5.3.2 is missing, no dependency information available
Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/io/confluent/kafka-connect-avro-converter/5.3.2/kafka-connect-avro-converter-5.3.2.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.427 s
[INFO] Finished at: 2021-10-21T10:39:36+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "confluent" could not be activated because it does not exist.
[ERROR] Failed to execute goal on project kafka-connect-avro-converter-shaded: Could not resolve dependencies for project org.apache.pulsar:kafka-connect-avro-converter-shaded:jar:2.8.0: Could not find artifact io.confluent:kafka-connect-avro-converter:jar:5.3.2 in aliyunmaven (https://maven.aliyun.com/repository/public) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

3. 原因分析

虽然阿里云不存在这个jar包,但我们手动放到了maven的本地库中,重新打包后还是提示抄不到pom文件。

如下:

在这里插入图片描述

猜测可能是lastUpdate的问题,但是删除后仍然不能成功。

经过各种尝试,下面方法可行。

4. 解决办法

删除_remote.repositories和pom文件。

4.1 原始状态

目录文件:

在这里插入图片描述

错误日志:

[WARNING] The requested profile "confluent" could not be activated because it does not exist.
[ERROR] Failed to execute goal on project kafka-connect-avro-converter-shaded: Could not resolve dependencies for project org.apache.pulsar:kafka-connect-avro-converter-shaded:jar:2.8.0: io.confluent:kafka-connect-avro-converter:jar:5.3.2 was not found in https://maven.aliyun.com/repository/public during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of aliyunmaven has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

4.2 删除_remote.repositories

目录结构:

在这里插入图片描述

错误日志:

[WARNING] The requested profile "confluent" could not be activated because it does not exist.
[ERROR] Failed to execute goal on project kafka-connect-avro-converter-shaded: Could not resolve dependencies for project org.apache.pulsar:kafka-connect-avro-converter-shaded:jar:2.8.0: Failed to collect dependencies at io.confluent:kafka-connect-avro-converter:jar:5.3.2: Failed to read artifact descriptor for io.confluent:kafka-connect-avro-converter:jar:5.3.2: io.confluent:kafka-schema-registry-parent:pom:5.3.2 was not found in https://maven.aliyun.com/repository/public during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of aliyunmaven has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

4.3 删除pom文件

目录结构:

在这里插入图片描述

错误日志:

[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing F:\code\tmp\pulsar\kafka-connect-avro-converter-shaded\target\kafka-connect-avro-converter-shaded.jar with F:\code\tmp\pulsar\kafka-connect-avro-converter-shaded\target\kafka-connect-avro-converter-shaded-2.8.0-shaded.jar
[INFO] Dependency-reduced POM written at: F:\code\tmp\pulsar\kafka-connect-avro-converter-shaded\dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.882 s
[INFO] Finished at: 2021-10-21T16:21:55+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "confluent" could not be activated because it does not exist.

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • Java基础之内存泄漏与溢出详解

    Java基础之内存泄漏与溢出详解

    今天带大家来了解一下Java内存泄漏与溢出的知识,文中有非常详细的介绍,对正在学习Java基础的各位小伙伴呢很有帮助哟,需要的朋友可以参考下
    2021-05-05
  • 关于Maven依赖冲突解决之exclusions

    关于Maven依赖冲突解决之exclusions

    这篇文章主要介绍了关于Maven依赖冲突解决之exclusions用法,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2021-12-12
  • java提取json中某个数组的所有值方法

    java提取json中某个数组的所有值方法

    下面小编就为大家分享一篇java提取json中某个数组的所有值方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-03-03
  • Java中Stream Filter多条件筛选过滤代码举例

    Java中Stream Filter多条件筛选过滤代码举例

    这篇文章主要给大家介绍了关于Java中Stream Filter多条件筛选过滤的相关资料,Java Stream中的filter方法可以使用多个条件来过滤数据,文中给出了详细的代码示例,需要的朋友可以参考下
    2023-12-12
  • Java实现表白小程序

    Java实现表白小程序

    本文讲述了Java实现表白的代码实例。具有很好的参考价值,希望对大家有所帮助,一起跟随小编过来看看吧,具体如下:
    2018-05-05
  • Java函数式编程(九):Comparator

    Java函数式编程(九):Comparator

    这篇文章主要介绍了Java函数式编程(九):Comparator,本文是系列文章的第9篇,其它文章请参阅本文底部的相关文章,需要的朋友可以参考下
    2014-09-09
  • 16进制显示字节流技巧分享

    16进制显示字节流技巧分享

    这篇文章主要介绍了16进制显示字节流的技巧分享,需要的朋友可以参考下
    2014-02-02
  • Springboot下使用Redis管道(pipeline)进行批量操作

    Springboot下使用Redis管道(pipeline)进行批量操作

    本文主要介绍了Spring boot 下使用Redis管道(pipeline)进行批量操作,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-05-05
  • Java通过PowerMockito和Mokito进行单元测试的实现

    Java通过PowerMockito和Mokito进行单元测试的实现

    PowerMockito和Mockito都是Java语言中的测试框架,用于进行单元测试和集成测试,本文就来详细的介绍一下通过PowerMockito和Mokito进行单元测试,感兴趣的可以了解一下
    2023-08-08
  • Java中常见的几种四舍五入方法总结

    Java中常见的几种四舍五入方法总结

    在Java编程中四舍五入是一个常见的数学运算需求,下面这篇文章主要给大家介绍了关于Java中常见的几种四舍五入方法,文章通过代码介绍的非常详细,对大家的学习或者工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2024-08-08

最新评论