(我假设您的所有模块都有一个通用的父 pom。)
在父 pom 中定义一个属性:
<properties>
<globaleVersion>1.0.0</globalVersion>
</properties>
<dependencyManagement>
并在父 pom 中定义一个部分:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>${globalVersion}</version>
</dependency>
<dependency>
<groupId>A</groupId>
<artifactId>A</artifactId>
<version>${globalVersion}</version>
</dependency>
</dependencies>
</dependencyManagement>
并且在你的模块中定义依赖而不指定版本(maven会从父的dependencyManagement部分找到它)
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>test</artifactId>
</dependency>
<dependency>
<groupId>A</groupId>
<artifactId>A</artifactId>
</dependency>
</dependencies>