官方说明文档地址https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

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.
  • system
    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)
    This scope is only used on a dependency of type pom in the <dependencyManagement> section. It indicates that the specified POM should be replaced with the dependencies in that 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 -

(*) Note: it is intended that this should be runtime scope
instead, so that all compile dependencies must be explicitly listed -
however, there is the case where the library you depend on extends a
class from another library, forcing you to have available at compile
time. For this reason, compile time dependencies remain as compile scope
even when they are transitive.

<scope>,它主要管理依赖的部署。

  • compile,缺省值,适用于所有阶段,会随着项目一起发布。
  • provided,类似compile,期望JDK、容器或使用者会提供这个依赖。如servlet.jar。
  • runtime,只在运行时使用,如JDBC驱动,适用运行和测试阶段。
  • test,只在测试时使用,用于编译和运行测试代码。不会随项目发布。
  • system,类似provided,需要显式提供包含依赖的jar,Maven不会在Repository中查找它。

maven中scope参数说明的更多相关文章

  1. maven中scope

    scope maven中scope的默认值是compilescope的分类1)compile 默认是compile.compile表示被依赖项目需要参与当前项目的编译,包括后续的测试,运行周期也参与其 ...

  2. maven中scope标签详解

    前言 最近在做itoo的pom优化工作,发现对于maven依赖管理中的scope标签还是有不明白的地方,所以今天就来总结一下这方面的知识,scope在maven的依赖管理中主要负责项目的部署 mave ...

  3. maven中scope标签以及exclusions 记录

    scope的分类 1.compile:默认值 他表示被依赖项目需要参与当前项目的编译,还有后续的测试,运行周期也参与其中,是一个比较强的依赖.打包的时候通常需要包含进去 2.test:依赖项目仅仅参与 ...

  4. maven中scope标签作用

    scope 是用来限制 dependency 的作用范围的,影响 maven 项目在各个生命周期时导入的 package 的状态,主要管理依赖的部署. scope 的作用范围: (1)compile: ...

  5. maven中scope属性的

    Dependency Scope 在POM 4中,<dependency>中还引入了<scope>,它主要管理依赖的部署.目前<scope>可以使用5个值: * c ...

  6. [转]maven中scope详解

    在POM 4中,<dependency>中还引入了<scope>,它主要管理依赖的部署.目前<scope>可以使用5个值: * compile,缺省值,适用于所有阶 ...

  7. maven中scope标签各个值的意义

    在使用maven配置时,有时候会见到scope这个标签,但是总是记不住他们所对应的含义,现在整理一下,以后忘记了再来查看. 版权声明:本文为CSDN博主「MrZhangBaby」的原创文章,遵循 CC ...

  8. maven中scope属性有哪些

    compile,缺省值,适用于所有阶段,会随着项目一起发布. provided,类似compile,期望JDK.容器或使用者会提供这个依赖.如servlet.jar. runtime,只在运行时使用, ...

  9. 浅谈maven中的scope,systempath

    scope  maven中scope的默认值是compile scope的分类 1)compile 默认是compile.compile表示被依赖项目需要参与当前项目的编译,包括后续的测试,运行周期也 ...

随机推荐

  1. 将word转化为swf 进行如同百度文库的般阅读

    实现如同百度文库那样类似功能需要进行一系列转化,一般流程想将word转化为pdf格式,再将pdf格式转化为swf格式.在网页上显示其实都是swf格式内容. 首先将word转化为swf,需要调用com组 ...

  2. SSH框架之Struts(2)——Struts的执行流程之配置文件

    上篇我们大致了解了一下採用了Struts框架的web页面运行流程. 接下来的几篇我们通过Struts的源代码来学习一下Struts的内部原理. 当server启动的时候.server会依据配置文件初始 ...

  3. mysql 5.7 多源复制 原创

    一从两主:多源复制 每台mysql 服务器都需要加my.cnf要加两个参数才可以在GTID多源复制 master-info-repository=TABLE relay-log-info-reposi ...

  4. ubuntu下tomcat启动巨慢分析

    在一个ubuntu14新环境部署tomcat,通过CI启动一个应用时,启动耗时达到15分钟之久.仔细看tomcat输出的耗时统计日志发现如下日志: Creation of SecureRandom i ...

  5. 怎样用通用pe工具箱制作U盘启动盘

    U盘启动盘制作过程,随着网络的普及,电脑已经成为我们日常生活中的重要一环,最近自己重装了下电脑系统,无意中发现一个傻瓜式的U盘装系统方法,就把怎么制作通用pe工具箱u盘启动盘的经验拿出来跟大家分享下. ...

  6. C++的64位整数

    在做ACM题时,经常都会遇到一些比较大的整数.而常用的内置整数类型常常显得太小了:其中long 和 int 范围是[-2^31,2^31),即-2147483648~2147483647.而unsig ...

  7. Linux添加快捷启动方式 (Ubuntu Debian CentOS)

    ubuntu桌面快捷方式的创建 debian添加快捷启动方式 centos 6 桌面建立应用程序的快捷方式的方法   今天用着用着ubuntu,突然抽搐了,感觉特别别扭,特别不方便.新装的应用程序不好 ...

  8. B - 一行盒子

    Description 你有一行盒子,从左到右依次编号为1, 2, 3,…, n.你可以执行四种指令: 1 X Y表示把盒子X移动到盒子Y左边(如果X已经在Y的左边则忽略此指令).2 X Y表示把盒子 ...

  9. A Simple Problem with Integers(线段树入门题)

    Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. On ...

  10. request 和response 中的setCharacterEncoding区别

    response和request的setCharacterEncoding 一.request.setCharacterEncoding():是设置从request中取得的值或从数据库中取出的值. 指 ...