zoukankan      html  css  js  c++  java
  • maven课程 项目管理利器-maven 3-7 maven依赖范围 2星

    本节主要讲了maven的依赖范围:

    在pom.xml   dependency标签的scope中。eclipse中有编译的路径,maven中有编译,运行,测试的路径。

    1  scope为test,为测试路径,多为junit jar包

    2  scope为compile,为默认级别,编译测试运行都有效

    3  scope为provided,编译和测试的时候有效

    4  scope为runtime,运行和测试的时候有效  (如:jdbc驱动的实现)

    5  scope为system,和compile一致,但是可移植能力差,引用的java_home(环境变量),更换电脑后将不能正常工作

    6  scope为import,它只使用在dependencyManager中,表示从其他的pom中导入dependency的配置。

    自己理解的:

    maven编译需要jar包,运行需要jar包,测试也需要jar包。

    scope为test:

                <dependency>
                    <groupId>junit</groupId>            <!-- 此处是包名-->
                    <artifactId>junit</artifactId>    <!-- 此处是项目名-->
                    <version>4.1.0</version>            <!-- 此处是maven版本号-->
                    <scope>test</scope>
                </dependency>

    scope为import:

    <dependency>
            <groupId>maven</groupId>
            <artifactId>A</artifactId>
            <version>1.0</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>

    maven官网关于依赖机制的介绍:

    http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

  • 相关阅读:
    Git 从入门到入坑
    单件模式(单例模式)
    装饰者模式
    观察者模式
    设计模式入门
    SpringBoot + Mybatis + Redis 整合入门项目
    Spring Boot 前后端交互及参数传递
    Spring Securtiy 认证流程(源码分析)
    Spring Boot 静态页面跳转
    第一条手机验证码
  • 原文地址:https://www.cnblogs.com/1446358788-qq/p/9898938.html
Copyright © 2011-2022 走看看