Maven知识点汇总

  • maven中的依赖关系
    • 直接依赖:如果A导入了B包,则是直接依赖
    • 简介依赖:如果A导入了B,B导入了C, 则是间接依赖。
  • 解决jar包依赖冲突的三个原则
    • 第一声明优先原则:哪个jar在靠上的位置,就用哪一个
    • 路径近者优先原则:直接依赖就比间接依赖路径近
    • 排除依赖:用exclusion排除依赖
    • 版本锁定 例如:
      • <properties>
        <junit.version>4.12</junit.version>
        <spring.version>5.0.5.RELEASE</spring.version>
        <pagehelper.version>4.1.4</pagehelper.version>
        </properties>
        <dependencyManagement>
        <dependencies>
        <!-- Spring -->
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
        </dependency>
        </dependencies>
        </dependencyManagement>
  • 同一个依赖在项目中出现多次,就成为依赖冲突
  • 继承:指的是子模块继承父模块的pom文件
    • <parent>
      <artifactId>new_health_parent</artifactId>
      <groupId>com.ssw</groupId>
      <version>1.0-SNAPSHOT</version>
      </parent>
  • 聚合:指的是父工程聚合了许多子模块,操作父工程可以连带着操作子模块
    • <modules>
      <module>health_common</module>
      <module>health_service_provider</module>
      <module>health_backend</module>
      <module>health_interface</module>
      <module>health_mobile</module>
      </modules>

猜你喜欢

转载自www.cnblogs.com/shangyunlin/p/12459890.html