关于maven项目中
<dependencyManagement>
标签使用的问题
问题描述:
对于pom.xml中<dependencyManagement>使用,我的理解是,子项目需要与父项目中groupId
和artifactId
对应,才能匹配上版本号。
但是这种情况,子项目只有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>,版本号
请老师帮忙解答下?