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

智能推荐

解决PS等软件出现应用程序无法正常启动(0xc000007b)_photoshop应用程序无法正常启动0xc000007b。请单击“确认”关闭应用程序。-程序员宅基地

文章浏览阅读3.9w次,点赞2次,收藏9次。  在使用电脑办公过程中,安装应用程序时难免遇到无法安装或者无法正常启动的问题,这对我们使用电脑带来了诸多不便。那遇到应用程序无法正常启动的问题要如何解决呢?相信大家肯定都是十分疑问的,每次都是只能忍痛重新安装软件。今天,小编就和大家探讨下应用程序无法正常启动的解决方法,帮助大家排忧解难。0xc000007b电脑图解1  第一种方案:SFC检查系统完整性来尝试修复丢失文件  1、打开电脑搜索输入cmd.exe,选择以管理员身份运行,跳出提示框时选择继续。0xc000007b电脑图解2_photoshop应用程序无法正常启动0xc000007b。请单击“确认”关闭应用程序。

oracle介质恢复和实例恢复的异同-程序员宅基地

文章浏览阅读396次。1、概念 REDO LOG是Oracle为确保已经提交的事务不会丢失而建立的一个机制。实际上REDO LOG的存在是为两种场景准备的:实例恢复(INSTANCE RECOVERY);介质恢复(MEDIA RECOVERY)。 实例恢复的目的是在数据库发生故障时,确保BUFFER CACHE中的数据不会丢失,不会造成数据库的..._oracle 实例恢复和介质恢复

Map中的putAll方法_java map putall-程序员宅基地

文章浏览阅读7k次。HashMap map1=new HashMap(); HashMap map2 = new HashMap();map2.putAll(map1)上面的代码的意思是将map1中所有的<key,value>插入到map2中去。具体参考: HashMap map1=new HashMap(); map1.put("..._java map putall

基于javaweb仿京东商城管理系统的设计与实现(含论文和程序源码及数据库文件)_基于java web的网店管理系统的设计与实现-程序员宅基地

文章浏览阅读1w次,点赞8次,收藏60次。网上购物商城系统以弥补传统购物方式的弊端。在目前的商城里,如果采用网上商城方式,用户购物时就不需要到店里面排队,这样不仅能实时地了解商品的特色,而且方便了顾客,同时也减轻了商城的服务压力。随着WLAN技术的普及,一些规模较大的商城开始考虑利用这种最为先进、最具时尚潮流的网络技术来建设一套灵活、快捷的信息管理系统,以优化管理流程,使网上的服务和管理得到实质性的提升,提高品牌形象和行业核心竞争力。 本课题是实现了网上购物系统的功能,如:商品分类、订单管理等功能。本设计采用安装 JAVA JDK 、安装 IDEA_基于java web的网店管理系统的设计与实现

Python数据爬取超详细讲解(零基础入门,老年人都看的懂)_python爬取数据-程序员宅基地

文章浏览阅读10w+次,点赞9k次,收藏2.4w次。关于Python爬虫的超详细讲解,用例子来给大家一步步分析爬虫的代码原理,由浅入深,老年人来了,我也给你整明白。_python爬取数据

发送邮件工具类_发送邮件 filestoragetype-程序员宅基地

文章浏览阅读250次。发送邮件工具类package com.wfsc.utils;import com.wfsc.entity.User;import javax.mail.MessagingException;import javax.mail.Session;import javax.mail.Transport;import javax.mail.internet.InternetAddress;import javax.mail.internet.MimeMessage;import java.io_发送邮件 filestoragetype

随便推点

C++解析XML文件_c++ xml解析-程序员宅基地

文章浏览阅读7.9k次,点赞17次,收藏110次。C++读取XML文件_c++ xml解析

R语言使用caret包的train函数构建多元自适应回归样条(MARS)模型构建分类模型、trainControl函数设置交叉验证参数、自定义调优评估指标_多元自适应回归样条 r-程序员宅基地

文章浏览阅读235次。R语言使用caret包的train函数构建多元自适应回归样条(MARS)模型构建分类模型、trainControl函数设置交叉验证参数、自定义调优评估指标、tuneLength参数和tuneGrid参数超参数调优_多元自适应回归样条 r

Android ListView控件显示数据库中图片_安卓获取listview里的图片并显示-程序员宅基地

文章浏览阅读5.8k次。Android中ListView是比较常用的控件,但一直都觉得创建ListView步骤有点繁琐,故在此总结一下,方便查阅。程序效果是实现一个显示联系人的简单信息。使用ListView控件,数据有姓名,和照片,并加入点击事件响应。布局文件:

python123程序改错题库,2016最新二级C语言考试题库及答案(程序改错专项练习 精华版)...-程序员宅基地

文章浏览阅读535次。《2016最新二级C语言考试题库及答案(程序改错专项练习 精华版)》由会员分享,可在线阅读,更多相关《2016最新二级C语言考试题库及答案(程序改错专项练习 精华版)(4页珍藏版)》请在人人文库网上搜索。1、程序改错题(共15题)1、在考生文件夹下,给定程序MODI.C的功能是:求一维数组a中所有元素的平均值,结果保留两位小数。例如,当一维数组a中的元素为:10,4,2,7,3,12,5,34,5..._安徽二级python考试有程序改错题吗?

Roser S.Pressman在UMLChina交流实录-程序员宅基地

文章浏览阅读2.2k次。 UMLChina第十三期专家交流实录返回首页 返回目录北京时间2002年1月10日(星期四)晚上21:30-23:30 嘉宾:Roser S.Pressman博士是软件工程领域国际知名的咨询专家和作者,R.S. Pressman & Associates, Inc的创始人,已有超过30年的产业经验,主要从事工程产品软件和系统软件的开发技术工

【Linux】shell编程1(shell脚本书写格式、脚本中的环境变量、普通变量、自定义环境变量、变量数组、位置变量、状态变量、内置变量、变量扩展)_linux脚本格式-程序员宅基地

文章浏览阅读2.4k次。${parameter:-word}如果parameter的变量值为空或者未赋值,则会返回word字符串代替变量值${parameter:=word}如果parameter的变量值为空或者未赋值,则设置这个变量值为word,返回值也是word${parameter:?word} 如果parameter的变量值为空或者未赋值,那么word字符串会被当做标准错误输出,否则输出变量的值${parameter:+word} 如果parameter的变量值为空或者未赋值,则输出空值,否则wo_linux脚本格式

推荐文章

热门文章

相关标签