當遇到 Maven 依賴沖突時,可以采取以下幾種方法來解決:
mvn dependency:tree
來查看項目的依賴樹,找出沖突的依賴。<dependency>
<groupId>com.example</groupId>
<artifactId>example-artifact</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>com.example</groupId>
<artifactId>conflicting-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>conflicting-artifact</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
總之,解決 Maven 依賴沖突需要理解項目的依賴關系,并采取相應的方法來解決沖突。