关于maven项目中

<dependencyManagement>

标签使用的问题



问题描述:

对于pom.xml中<dependencyManagement>使用,我的理解是,子项目需要与父项目中groupIdartifactId对应,才能匹配上版本号。

但是这种情况,子项目只有groupId与父<dependencyManagement>中的groupId匹配上了,artifactId没有匹配上,但却仍然匹配上了了版本号,这是为什么?

具体例子:


父项目:

<dependencyManagement>
 <dependencies>
   <dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-dependencies</artifactId>
     <version>Greenwich.SR5</version>
     <type>pom</type>
     <scope>import</scope>
   </dependency>
 </dependencies>
</dependencyManagement>



子项目:

<dependencies>
 <dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
 </dependency>
 <dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
 </dependency>
</dependencies>



我的理解是:子项目根据<groupId>org.springframework.cloud</groupId>与父项目<dependencyManagement>中groupId匹配上了,由于父项目中<artifactId>spring-cloud-dependencies</artifactId>里面含有   <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>和

   <artifactId>spring-cloud-starter-netflix-zuul</artifactId>,所以也能匹配上,匹配的版本号就是与父项目<artifactId>spring-cloud-dependencies</artifactId>中对应的

<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>和

   <artifactId>spring-cloud-starter-netflix-zuul</artifactId>,版本号



请老师帮忙解答下?

相关课程:JAVA 全系列>第十九阶段:Spring Cloud微服务技术栈>Spring Cloud>如何选择SpringCloud版本

©2014-2023 百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备13018289号-12    营业执照    经营许可证:京B2-20212637