我有这两个 pom 文件:
1) 父 pom.xml
...
<modules>
<module>web-module</module>
<module>interface-module</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}.${project.artifactId}</groupId>
<artifactId>interface-module</artifactId>
<version>${project.version}</version>
<type>ejb</type>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
2) 子 pom.xml
<dependencies>
<dependency>
<groupId>${project.parent.groupId}.${project.parent.artifactId}</groupId>
<artifactId>interface-module</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
问题是:
为什么它无法解决由父依赖管理管理的依赖项,而子项中省略了版本?为什么在对从聚合这些模块的父级继承的子模块使用dependencyManagment 时必须指定版本?也许一些建议?
UPD:事实证明,当子项的 groupId 发生更改并且不是从父项继承的那个时,这种行为存在......基本上我有父项的 2 个子模块,它们都是父项的子项。当我更改子模块中的 groupId 时,它要求我在依赖管理期间指定版本,这有点奇怪。任何想法为什么 Maven 会那样做?