一、问题描述

我这里上传了jar到远程仓库,然后将本地仓库里的相关jar全部删除,刷新了下引入该依赖的项目,让他从远程仓库下载下来,看是否可用,编译的过程中会报如下的错误:

[WARNING] The POM for com.xxx:xxx-xxx:jar:1.0.6 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.xxx:xxx-xxx:jar:1.0.6 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.xxx:xxx-xxx:jar:1.0.6 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.xxx:xxx-xxx:jar:1.0.6 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

这几个jar包有问题,报上面的错误基本上是由以下两个问题引起的:
1.网络问题,导致jar没下载完成
2.依赖传递的问题,可能是父pom.xml没有打包安装发布

二、解决方法

第一种很好解决,将本地仓库中的jar删除掉,让他重新下载。

第二种的话,可以先通过以下命令打印依赖树:

mvn -X dependency:tree>tree.txt

在这里插入图片描述
找到有问题的jar,我这有问题的那几个jar都是在某个工程里的,模块结构如下:

root
   <modules>
        <module>a</module>
        <module>b</module>
        <module>c</module>
    </modules>

我发布到中央仓库的时候,并没有将root项目发布上去,只将root下的子模块发布上去了,所以在root项目下重新安装一下本地就能打包通过了,或者通过如下命令,只安装父依赖,不处理子模块:

mvn install -N

但是我这是发布到中央仓库去的,肯定不能本地安装,但是又不能将root项目也发布上去,因为root下的有些模块是内部的,所以只能将root项目的pom.xml删除,删除了问题也不大,不让他管理整个项目,root模块下的pom.xml也只是为了打包方便而已,只执行一次就能将该项目下的所有模块打包,手动一个一个编译发布上去。

GitHub 加速计划 / de / Dependencies
37
1
下载
A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues.
最近提交(Master分支:2 个月前 )
1997a400 - 3 年前
2f423539 - 3 年前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐