Maven dependency scope_maven dependent scope-程序员宅基地

技术标签: Java  Maven  

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.
  • 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.

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/youhan26/article/details/45874333

智能推荐

(附源码)springboot基于微信小程序的校园体育运动场地及器材租凭系统设计与实现 毕业设计131052-程序员宅基地

文章浏览阅读242次。校园体育运动场地及器材租凭系统 的设计主要是对系统所要实现的功能进行详细考虑,确定所要实现的功能后进行界面的设计,在这中间还要考虑如何可以更好的将功能及页面进行很好的结合,方便用户可以很容易明了的找到自己所需要的信息,还有系统平台后期的可操作性,通过对信息内容的详细了解进行技术的开发。校园体育运动场地及器材租凭系统的开发利用现有的成熟技术参考,以源代码为模板,分析功能调整与校园体育运动场地及器材租凭系统的实际需求相结合,讨论了基于校园体育运动场地及器材租凭系统的使用。

高性能计算(HPC)-一文全面理解高性能计算_hpc领域-程序员宅基地

文章浏览阅读1.5k次,点赞31次,收藏24次。AI的疯狂发展以及视频、图像、音频、3D数据的迫切需要,导致传统的CPU不能满足这样大算力的计算。由于这些数据的运算多是一些简单的运算,因此需要设计出多个算术运算单元的芯片来应对这种少控制多计算的场景。这是并行计算、高性能计算诞生的重要动力。为了适配这样的场景,设计出了以GPU为核心的并行处理芯片、包括DSP、VPU、DPU、NPU等。本文主要介绍基于这些芯片以及网络、系统引入的高性能计算,比较全面的介绍高性能计算,希望对高性能计算的理解起到一个宏观的作用。:一个全栈工程师的升级之路!_hpc领域

俄亥俄大学计算机科学专业,美国计算机科学专业最新排名!-程序员宅基地

文章浏览阅读145次。1 Carnegie Mellon University 卡内基梅隆大学1 Massachusetts Institute of Technology 麻省理工学院1 Stanford University 斯坦福大学1 University of California -Berkeley 加州大学伯克利分校5 Cornell University 康奈尔大学5 University of Ill..._俄亥俄大学计算机科学专业

socket编程:socket()函数详解-程序员宅基地

文章浏览阅读1.9w次,点赞19次,收藏88次。文章目录1. 什么是socket?1.1 意义1.2 本质1.3 应用1.4 结论2. socket() 函数参数介绍2.1 参数1:int af2.2 参数2:int type2.3 参数3:int protocol3. socket()函数返回值介绍1. 什么是socket?套接字函数创建一个绑定到特定传输服务提供者的套接字。将底层复杂的协议体系,执行流程,进行了封装,封装完的结果,就是一个SOCKET了,也就是说,SOCKET是我们调用协议进行通信的操作接口。1.1 意义将复杂的协议过程与我_socket()

基于python+opencv的DCT(离散余弦变换)实验-程序员宅基地

文章浏览阅读2.5w次,点赞24次,收藏84次。离散余弦变换是图像处理中非常常用的算法,可以用于jpg图像压缩等领域。数学原理我就不扯了,网上一大堆。但介于网上实在没有关于python+opencv来实现DCT的好文章(至少木盏没有搜到过)。于是稍微写一个博文做一个总结,给后人便利。要用到的模块是opencv,安装方法看另一篇文章《opencv快速安装》python==3.6.5opencv==3.1.0scipy==1.1.0...

【前后端】django前后端交互_前后端数据是交互用的什么软件-程序员宅基地

文章浏览阅读567次,点赞4次,收藏11次。随着开发语言及人工智能工具的普及,使得越来越多的人会主动学习使用一些开发语言,本文主要介绍django前后端交互的基础内容。以上就是今天要讲的内容,这些步骤提供了一种简单的方式来实现 Django 应用的前后端交互。在实际项目中,你可能需要处理更复杂的逻辑和数据,并且可以使用 Django REST Framework 等工具来简化 RESTful API 的开发。_前后端数据是交互用的什么软件

随便推点

分享Silverlight/WPF/Windows Phone/HTML5一周学习导读(11月28日-12月4日)-程序员宅基地

文章浏览阅读1.6k次。分享Silverlight/WPF/Windows Phone/HTML5一周学习导读(11月28日-12月4日)本周Silverlight学习资源更新Silverlight HttpUtil 封装Post调用nivana999Silverlight中Grid.ColumnDefinitions属性设置错误xjbestSilverli

工业互联网平台选型星级评估申请要求-程序员宅基地

文章浏览阅读116次,点赞5次,收藏3次。工业互联网

iPhone网页显示不全(被遮挡)怎么办?-程序员宅基地

文章浏览阅读1.2w次。iPhone网页显示不全(被遮挡)怎么办?今天再次遇到了这样一个历史遗留问题:我们在用iPhone浏览部分网页时,有时候会出现部分选项被界面遮挡的情况,如:

在eclipse中使用vim-程序员宅基地

文章浏览阅读52次。转自:http://blog.csdn.net/eplaylity/article/details/6168283 1. vrapper(开源) 直接从eclipse安装即可,地址:http://vrapper.sourceforge.net/update-site/stable/ 2. viplugin(收费) 下载后,拷贝到eclipse相应目录即可,地址 http://www.vip..._在eclipse中配置vim编辑

使用JDK命令排查故障实战案例详解_jdk巡检的检查项-程序员宅基地

文章浏览阅读2.2k次,点赞8次,收藏12次。文章目录服务器CPU使用率达到99%程序发生了死锁java应用大量消耗内存 学习了JDK命令,就是为了排查故障的,今天通过几个分类来了解在程序遇到故障的时候,如果使用JDK命令排查问题服务器CPU使用率达到99% 这里我们先写一个demo,写一个死循环..._jdk巡检的检查项

Geoserver的一些关键设置(持续更新)_- found system environment variablegeoserver_data_-程序员宅基地

文章浏览阅读2.3k次。关于geoserver的data_dir目录使用geoserver时特别注意,所有的数据都保存在 data_dir中,data_dir目录存储了workspace、data store、featuretype、layergroup等设置在使用 tomcat部署时,如果一不小心undeploy了,程序丢了,如果data_dir也在程序目录里面,那就.....所以,在环境变量中添加GEOSE..._- found system environment variablegeoserver_data_dir set to /geoserver_tile