maven下载依赖包报错 Failed to read artifact descriptor for com.xxx:test-interface:jar:1.0.0

一、报错情形

   1、项目构架

     存在三个功能模块(各自独立的),有功能模块 test 、test1、test2
     test中存在test-interface子模块,test1中存在test1-interface子模块,test2中存在test2-server子模块
     test1-interface 依赖于 test-interface子模块,而 test2-server 依赖于 test1-interface子模块、同时依赖于 test-interface子模块
   架构图如下:
在这里插入图片描述

   2、报错信息

     test1报错:

      Failed to execute goal on project test1-interface: Could not resolve dependencies for project com.xxx:
test-interface:jar:1.0.0: Failed to collect dependencies at com.xxx:test-interface:jar:1.0.0: Failed to read 
artifact descriptor for com.xxx:test-interface:jar:1.0.0: Could not find artifact com.xxx:test:pom:1.0.0 in AAA
(http://xxx.xxx.xxx.xxx:8081/xxx/xxx) -> [Help 1]

  翻译如下:
      无法在项目产品上执行目标 - 通用:无法解析项目com.xxx的依赖项:test1-interface:1.0.0:无法在com.xxx收集依赖项:
test-interface:jar:1.0.0:无法读取com.xxx的工件描述符:test-interface:jar:1.0.0:在AAA中找不到工件com.xxx:test:pom:
1.0.0(http://xxx.xxx.xxx.xxx:8081/xxx/xxx)

  大致理解:
      在 test1 中存在不可解析的类或方法,因为所 test-interface 包不存在,其原因是因为在指定路径
(http://xxx.xxx.xxx.xxx:8081/xxx/xxx)中不存在这个依赖包

     test2报错:

      Failed to execute goal on project test2-server: Could not resolve dependencies for project com.xxx:
test1-interface:jar:1.0.0: Failed to collect dependencies at com.xxx:test1-interface:jar:1.0.0: Failed to read 
artifact descriptor for com.xxx:test1-interface:jar:1.0.0: Could not find artifact com.xxx:test1:pom:1.0.0 in AAA
(http://xxx.xxx.xxx.xxx:8081/xxx/xxx) -> [Help 1]

  翻译如下:
      无法在项目产品上执行目标 - 通用:无法解析项目com.xxx的依赖项:test2-server:1.0.0:无法在com.xxx收集依赖项:
test1-interface:jar:1.0.0:无法读取com.xxx的工件描述符:test1-interface:jar:1.0.0:在AAA中找不到工件com.xxx:test1:pom:
1.0.0(http://xxx.xxx.xxx.xxx:8081/xxx/xxx)

  大致理解:
      在 test2 中存在不可解析的类或方法,因为所 test1-interface 包不存在,其原因是因为在指定路径
(http://xxx.xxx.xxx.xxx:8081/xxx/xxx)中不存在这个依赖包;而根据上面的架构图可知,其最根本原因是不存在 test-interface 包

   3、分析错误

     由上面可知,存在两种可能
       一是maven本地仓库没有这个依赖包,并且配置文件中的远程仓库路径错误(不存在这个依赖包)
       二是maven本地仓库没有这个依赖包,并且本地没有打包生成依赖包(针对3个功能模块都在本地)
在这里插入图片描述

二、错误解决

   1、原因一解决方案

     该原因主要是在本地没有 test 功能模块时,才可能存在
     若是本地有 test 功能模块,可直接在本地打包生成依赖包(具体见原因二解决方案)

   2、原因二解决方案

     从根本入手:
       先生成 test-interface 子模块的包,在处理 test功能模块(解决 test1 报错)

       再生成 test1-interface 子模块的包,再处理 test1 功能模块(解决 test2 报错)

   3、解决如图

在这里插入图片描述

三、注意事项

父工程的 pom 文件中加入maven的编译依赖组件; 需指定与idea所用java通个版本的jdk编译
在与其他工程(包括子工程与子工程之间)存在依赖关系时, 必要的组件
并且在打包编译时, 需要 先clean install一下父工程 ; 再走各个子工程的打包编译

<build>
        <pluginManagement>
            <plugins>
                <!-- 加入maven的打包依赖组件; SpringBoot的组件 -->
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <!-- 加入maven的编译依赖组件; 需指定与idea所用java通个版本的jdk编译 -->
                <!-- 在与其他工程(包括子工程与子工程之间)存在依赖关系时, 必要的组件 -->
                <!-- 并且在打包编译时, 需要先clean install一下父工程; 再走各个子工程的打包编译 -->
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <!-- 一般而言,target与source是保持一致的,
                        但是,有时候为了让程序能在其他版本的jdk中运行
                        (对于低版本目标jdk,源代码中没有使用低版本jdk中不支持的语法),
                        会存在target不同于source的情况 -->
                        <!-- 源代码使用的开发版本 -->
                        <source>1.8</source>
                        <!-- 需要生成的目标class文件的编译版本 -->
                        <target>1.8</target>
                        <encoding>utf-8</encoding>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值