zoukankan      html  css  js  c++  java
  • maven之聚合继承

    聚合

    [多模块Maven项目]
    当项目以多模块的形式构建的时候,需要每个依赖模块单独编译,而聚合即实现统一编译. 目的是方便快速构建

      <packaging>pom</packaging>
      
      <modules>
    	 <module>account-persist</module>
         <module>account-service</module>
         <module>account-core</module>
    	 <module>account-utils</module>
    	 <module>account-web</module>
      </modules>
    
    目录结构
    ----pom.xml // parent pom 用于聚合构建
    ----account-core             // 模块
                   --- pom.xml
    			   --- src
    ----account-service          // 模块
                   --- pom.xml
    			   --- src
    
     *  聚合模块并不一定是父子关系 可以平级关系聚合; 引用方式<module>../../a</module>以相对路径查找关联模块
    

    继承

    多模块项目pom中包含很多配置信息是重复的,后续变更修改的时候,改动较大
    通过继承的方式来实现统一管理可继承的属性; 目的时消除重复配置

      groupId : 项目组ID
      version: 项目版本
      desription: 项目描述
      organization: 组织信息
      inceptionYear: 创始年份
      url: 项目url地址
      developers: 开发着信息
      contributors: 贡献者信息
      distributionManagement: 部署发布信息
      issueManagement: 缺陷跟踪系统信息
      ciManagement: 持续集成系统信息
      scm: 版本控制系统信息
      mailingLists: 邮件列表信息
      properties: 自定义maven属性
      dependencies: 依赖配置
      dependencyManagement: 项目依赖管理配置
      repositories: 仓库位置
      build: 配置源码目录、输出目录、插件配置、插件管理配置
      reporting: site报告输出目录配置、报告插件配置
      
    

    版本控制

    • 如果所有依赖包在parent中申明依赖,则无需依赖任何依赖的工具包也会继承依赖;这是不合理的
    • 通过 dependencyManagement 申明依赖,继承后并不会真实引入依赖,而定义依赖(不申明版本)会继承dependencyManagement申明的版本号
    • dependencyManagement 方便统一管理依赖的版本
    • 除继承外,还可以通过import来引入依赖管理 type: pom
    • 插件管理与依赖包管理相同 , 插件管理 [< pluginManagement >]
    <properties>
    	<springframework.version>2.5.6</springframework.version>
    </properties>
    
    <dependencyManagement>
    	<dependencies>
    		<dependency>
    			<groupId>xx</gropuId>
    			<artifactId>dd</artifactId>
    			<version>${springframework.version}</version>
    		</dependency>
    	</dependencies>
    </dependencyManagement>
    
       <dependencyManagement>
       	<dependencies>
       		<dependency>
       			<groupId>xx</gropuId>
       			<artifactId>dd</artifactId>
       			<version>1.0</version>
    			<type>pom</type>
    			<scope>import</scope>
       		</dependency>
       	</dependencies>
       </dependencyManagement>
    
    <build>
    	<pluginManagement>
    		<plugin>
    			xxxx
    		</plugin>
    	</pluginManagement>
    </build>
    
  • 相关阅读:
    D django 用户认证系统
    vim 跳到指定行
    django 的auth.authenticate返回为None
    git fetch 的简单用法:更新远程代码到本地仓库
    sql语句查询出表里符合条件的第二条记录的方法
    你一定喜欢看的 Webpack 2.× 入门实战
    webpack 从入门到工程实践
    入门Webpack,看这篇就够了
    教程
    常用浏览器如何设置代理服务器上网(图文教程)
  • 原文地址:https://www.cnblogs.com/pengsn/p/13643941.html
Copyright © 2011-2022 走看看