Maven 解决依赖冲突有以下几种方式:
<exclusions> 标签来排除特定的依赖项。例如:<dependency>
    <groupId>group1</groupId>
    <artifactId>artifact1</artifactId>
    <version>1.0</version>
    <exclusions>
        <exclusion>
            <groupId>group2</groupId>
            <artifactId>artifact2</artifactId>
        </exclusion>
    </exclusions>
</dependency>
这样就会排除掉 group1:artifact1 依赖中的 group2:artifact2。
<dependency>
    <groupId>group1</groupId>
    <artifactId>artifact1</artifactId>
    <version>1.0</version>
</dependency>
<dependency>
    <groupId>group2</groupId>
    <artifactId>artifact2</artifactId>
    <version>2.0</version>
</dependency>
<dependency>
    <groupId>group3</groupId>
    <artifactId>artifact3</artifactId>
    <version>3.0</version>
    <exclusions>
        <exclusion>
            <groupId>group2</groupId>
            <artifactId>artifact2</artifactId>
        </exclusion>
    </exclusions>
</dependency>
在上述例子中,group3:artifact3 依赖排除了 group2:artifact2,因此 Maven 会使用强制版本的 group2:artifact2。
<dependencyManagement> 标签下,可以定义项目中所有依赖项的版本。这样可以统一管理所有的依赖版本,避免冲突。例如:<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>group1</groupId>
            <artifactId>artifact1</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>group2</groupId>
            <artifactId>artifact2</artifactId>
            <version>2.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>
这样在项目中引入这些依赖时,不需要指定版本号,Maven 会自动使用 <dependencyManagement> 中定义的版本。
需要根据具体情况选择合适的解决冲突的方式。