當多模塊之間的依賴版本不一致時,可以采取以下幾種解決方法:
<properties>
<dependency.version>1.0.0</dependency.version>
</properties>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-artifact</artifactId>
<version>${dependency.version}</version>
</dependency>
</dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-artifact</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>com.example</groupId>
<artifactId>example-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-artifact</artifactId>
<version>2.0.0</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-artifact</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>another-artifact</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-artifact</artifactId>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>another-artifact</artifactId>
</dependency>
</dependencies>
以上是解決Maven多模塊依賴版本不一致問題的幾種常用方法,根據具體情況選擇適合的方法進行處理。