Maven传递依赖 无法引入解决办法

今天一个传递依赖问题搞了我半天,终于搞明白原因了。项目引入uecom-core.jar,uecom-core包A依赖了oshi-core,在IDEA里面只能看到依赖uecom-core,不管咋样都看不到依赖的oshi-core。

我在IDEA里打包后在控制台发现一个告警:

The POM for top.uecom:uecom-core:jar:1.1.3 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for top.uecom:uecom-core:1.1.3

原来是uecom-core.jar的pom依赖有问题。

问题排查

在项目根目录打印依赖树:

mvn dependency:tree>tree.txt

应用依赖树中出现警告。警告显示:应用引入的依赖包无效,依赖包中传递依赖项不可用,可以通过开启debug获取更多信息。

然后我开启debug功能,重新打印依赖树:

mvn -X dependency:tree>tree.txt

开启maven debug功能后,警告后紧跟了一条错误信息,如下

[WARNING] The POM for top.uecom:uecom-core:jar:1.1.3 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for top.uecom:uecom-core:1.1.3
[ERROR] 'dependencies.dependency.version' for cn.hutool:hutool-all:jar is missing. @ 
...

原来是uecom-core:jar包中引入的hutool-all无法获取版本号。

解决方案

在hutool-all中加上版本号重新发布,则一切正常。

你可能感兴趣的:(Maven传递依赖 无法引入解决办法)