一. 什么是传递依赖 冲突

A 依赖B, 引入A的时候也引入B
冲突: A依赖了B ,C 依赖B

二. 自带调优原则

a, 第一声明者优先
b, 路径近者优先

三. 排除依赖(方式一)

Maven 传递依赖和冲突解决

四. 方式二.锁定版本(推荐)

1, 提取版本号
 <properties>
	<maven.compiler.target>1.7</maven.compiler.target>
    <!--提取版本号-->
    <spring-version>5.0.2.RELEASE</spring-version>
    <mybatis-version>3.4.5</mybatis-version>
  </properties>
2、版本控制器
<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.2.5.RELEASE</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
 3、使用提取的版本号
 <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring-version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring-version}</version>
    </dependency>
  </dependencies>

五. 依赖范围对传递依赖的影响

Maven 传递依赖和冲突解决

相关文章: