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

今天一个传递依赖问题搞了我半天,终于搞明白缘由了。一个jar包A依赖了httpclient,而后另外一个jar包B引入A,在IDEA里面只能看到依赖A,无论咋样都看不到依赖httpclient。spring

我在IDEA的项目B里面,打包后在控制台发现一个告警:bash

the POM for A is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

原来是jar包A的pom依赖有问题。maven

问题排查

在应用B的根目录打印依赖树:spring-boot

mvn dependency:tree>tree.txt

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

[WARNING] the POM for A is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details...

而后我开启debug功能,从新打印依赖树:debug

mvn -X dependency:tree>tree.txt

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

[WARNING] The POM for com.huawei.dc.security:security-sdk-https:jar:1.0-SNAPSHOT is invalid, transitive dependencies (if any) will not be available: 2 problems were encountered while building the effective model for com.huawei.dc.security:security-sdk-https:1.0-SNAPSHOT
[ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-configuration-processor:jar is missing. @ 
[ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-autoconfigure:jar is missing. @ 
...

原来是A包中引入的另外的spring-boot-autoconfigure没加版本号,这个我觉得能继承父pom的版本号,发现这里不生效。具体缘由我再分析。继承

解决方案

在A中把版本号补上从新发布,则一切正常。ci

相关文章
相关标签/搜索