maven介绍

项目管理构建工具

Maven Ant Gradle

1.Maven的概念

Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建、报告和文档的软件项目管理工具。

2.如何window下搭建Maven环境

2.1在http://maven.apache.org下载maven

2.2安装maven后配置环境变量

如:在系统变量path中添加:D:\eclipse\apache-maven-3.5.3\bin

 

项目管理构建工具

Maven Ant Gradle

1.Maven的概念

Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建、报告和文档的软件项目管理工具。

2.如何window下搭建Maven环境

2.1在http://maven.apache.org下载maven

2.2安装maven后配置环境变量

如:在系统变量path中添加:D:\eclipse\apache-maven-3.5.3\bin

 

 

3.Maven的目录结构

 

 

4.pom.xml结构

 

 

 

5.Maven的常用命令

 

 

 

6.自动创建maven约定的目录骨架

使用archetype插件

 

 

 

 

 

 

7.maven仓库

Maven仓库分为本地仓库与远程仓库,一般在本地仓库中查找有无依赖,没有则到远程仓库查找下载,再没有则会报错

默认的中央仓库的地址:

https://repo.maven.apache.org/maven2

http://search.maven.org/

8.镜像仓库

9.maven的生命周期

执行某个阶段时其前面的阶段会被依次的顺序执行

 

 

 

 

 

10.pom常用标签备注

<!--指定当前pom的版本 -->

<modelVersion>4.0.0</modelVersion>

<!--反写的公司网址+項目名 -->

<groupId>com.zgk</groupId>

<!--项目名+模块名 -->

<artifactId>maven.test</artifactId>

<!--第一个0表示大版本号第二个0分支版本号 第三个0表示小版本号 snapshot快照版本(不稳定,尚处于开发中的版本) alpha内测版本 beta公测版本 release稳定版本 GA正式发布版本-->

<version>0.0.1-SNAPSHOT</version>

<!--默认是jar 还可以是war zip pom-->

<packaging>jar</packaging>

<!--项目名 -->

<name>hi</name>

<!--项目地址 -->

<url>http://maven.apache.org</url>

<!--项目描述 -->

<description></description>

<!--开发人员列 -->

<developers></developers>

<!--许可证信息 -->

<licenses></licenses>

<!--组织者信息-->

<organization></organization>

<!--依赖列表 -->

<dependencies>

  <dependency>

    <!--坐标groupId -->

    <groupId></groupId>

    <!--坐标artifactId  -->

    <artifactId></artifactId>

    <!--版本  -->

    <version></version>

    <!--类型  -->

    <type></type>

    <!--依赖的范围 如test表示测试范围内有效 -->

      <scope>test</scope>

      <!--设置依赖是否可选 true false-->

      <optional></optional>

      <!--排除依赖传递列表 -->

      <exclusions>

         <exclusion></exclusion>

      </exclusions>

  </dependency>

  </dependencies>

  <!-- 依赖管理,一般定义在父模块供子模块继承使用 -->

  <dependencyManagement>

     <dependencies>

         <dependency></dependency>

      </dependencies>

  </dependencyManagement>

 

  <!--构建行为  -->

  <build>

  <!--插件列表  -->

  <plugins>

    <plugin>

       <groupId></groupId>

       <artifactId></artifactId>

       <version></version>

    </plugin>

  </plugins>

  </build>

  <!-- 子模块在父模块中继承 -->

  <parent></parent>

  <!-- 聚合多个maven项 -->

  <modules>

     <module></module>

  </modules>

 

 

11.依赖的范围

Dependency scope is used to limit the transitivity of a dependency, and also to affect the classpath used for various build tasks.

There are 6 scopes available:

  • Compile 默认范围,编译测试运行都有效
    This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
  • Provided 在测试和编译的时候有效,运行的时候不会被加入
    This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
  • Runtime 在测试和运行时有效
    This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
  • Test 只在测试范围有效
    This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. This scope is not transitive.
  • System 与系统本机相关,可移植性差,如本机的Javahome,只能在本机有效
    This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
  • import (only available in Maven 2.0.9 or later)
  • 导入的范围,它只使用在dependencyManagement中,表示从其他的pom中导入dependecy的配置
    This scope is only supported on a dependency of type pom in the <dependencyManagement> section. It indicates the dependency to be replaced with the effective list of dependencies in the specified POM's <dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

Each of the scopes (except for import) affects transitive dependencies in different ways, as is demonstrated in the table below. If a dependency is set to the scope in the left column, transitive dependencies of that dependency with the scope across the top row will result in a dependency in the main project with the scope listed at the intersection. If no scope is listed, it means the dependency will be omitted.

 

compile

provided

runtime

test

compile

compile(*)

-

runtime

-

provided

provided

-

provided

-

runtime

runtime

-

runtime

-

test

test

-

test

-

 

12.依赖传递

 

 

 

 

13.依赖冲突

基本依据两条原则

  1. 短路优先(谁的路径短,用哪个)

 

 

2.先声明先优先(路径相同,谁先声明,先解析谁)

 

 

14.聚合继承

1.聚合

 

2.继承

 

转载于:https://www.cnblogs.com/kk-home/p/9195615.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本方法。编译原理不仅是计算机科学理论的重要组成部分,也是实现高效、可靠的计算机程序设计的关键。本文将对编译原理的基本概念、发展历程、主要内容和实际应用进行详细介绍编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本方法。编译原理不仅是计算机科学理论的重要组成部分,也是实现高效、可靠的计算机程序设计的关键。本文将对编译原理的基本概念、发展历程、主要内容和实际应用进行详细介绍编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本方法。编译原理不仅是计算机科学理论的重要组成部分,也是实现高效、可靠的计算机程序设计的关键。本文将对编译原理的基本概念、发展历程、主要内容和实际应用进行详细介绍编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本方法。编译原理不仅是计算机科学理论的重要组成部分,也是实现高效、可靠的计算机程序设计的关键。本文将对编译原理的基本概念、发展历程、主要内容和实际应用进行详细介绍编译原理是计算机专业的一门核心课程,旨在介绍编译程序构造的一般原理和基本

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值