日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

如何使用Maven scope

發布時間:2023/12/31 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何使用Maven scope 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

maven 有6個scope類型,下面簡單總結備忘下

<dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.4</version><scope>provided</scope> </dependency>

maven官方描述

Dependency Scope
Dependency scope is used to limit the transitivity of a depedency, 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.?

------------------------------------------------------------------------------------------------------------------------------------

翻譯下(以下內容載自:http://acooly.iteye.com/blog/1788890)

1.compile

編譯范圍,默認scope,在工程環境的classpath(編譯環境)和打包(如果是WAR包,會包含在WAR包中)時候都有效。

2.provided

容器或JDK已提供范圍,表示該依賴包已經由目標容器(如tomcat)和JDK提供,只在編譯的classpath中加載和使用,打包的時候不會包含在目標包中。最常見的是j2ee規范相關的servlet-api和jsp-api等jar包,一般由servlet容器提供,無需在打包到war包中,如果不配置為provided,把這些包打包到工程war包中,在tomcat6以上版本會出現沖突無法正常運行程序(版本不符的情況)。

3.runtime

一般是運行和測試環境使用,編譯時候不用加入classpath,打包時候會打包到目標包中。一般是通過動態加載或接口反射加載的情況比較多。也就是說程序只使用了接口,具體的時候可能有多個,運行時通過配置文件或jar包掃描動態加載的情況。典型的包括:JDBC驅動等。

4.test

測試范圍,一般是單元測試場景使用,在編譯環境加入classpath,但打包時不會加入,如junit等。

5.system

系統范圍,與provided類似,只是標記為該scope的依賴包需要明確指定基于文件系統的jar包路徑。因為需要通過systemPath指定本地jar文件路徑,所以該scope是不推薦的。如果是基于組織的,一般會建立本地鏡像,會把本地的或組織的基礎組件加入本地鏡像管理,避過使用該scope的情況。

實踐:

  • provided是沒有傳遞性的,也就是說,如果你依賴的某個jar包,它的某個jar的范圍是provided,那么該jar不會在你的工程中依靠jar依賴傳遞加入到你的工程中。
  • provided具有繼承性,上面的情況,如果需要統一配置一個組織的通用的provided依賴,可以使用parent,然后在所有工程中繼承。

總結

以上是生活随笔為你收集整理的如何使用Maven scope的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 一区免费观看 | 久久精品国产一区 | 熟妇人妻系列aⅴ无码专区友真希 | 久久精品国产熟女亚洲AV麻豆 | 伊人久久久久久久久久久 | 国产欧美精品久久久 | 欧美高清videos高潮hd | 啪啪免费av | 97se综合| 999色综合 | 无人码人妻一区二区三区免费 | 91色拍| 性高潮视频在线观看 | 成人免费在线视频 | 五月婷婷激情 | 中文字幕高清在线 | 中文字幕视频一区二区 | 精品在线免费观看 | 草碰在线 | 秋霞综合网 | 国产又爽又黄免费视频 | 亚洲第一伊人 | 国产啪视频 | 精品国产区一区二 | 日本少妇一级片 | 国产视频一级 | 叶山小百合av一区二区 | 激情综合区 | www天天干 | 日本熟妇毛茸茸丰满 | 中文字幕无码av波多野吉衣 | 国产精品怡红院 | 亚洲在线免费观看视频 | 日韩av在线网站 | 婷婷丁香激情 | 日日夜夜综合 | 秋霞久久精品 | 国产原创av在线 | 亚洲熟妇中文字幕五十中出 | 欧美一级片在线观看 | 国产一区二区不卡在线 | 天天操操操操 | 在哪里可以看毛片 | 国产一区二区视频免费观看 | 国内精品视频在线播放 | 欧美一区精品 | 香蕉视频网站 | 久操福利在线 | √资源天堂中文在线视频 | 成人毛片在线视频 | 天天爽夜夜爽夜夜爽精品视频 | 中文字幕精品久久久 | av在线电影网 | 少妇一级淫片日本 | 国产小视频网址 | 天天射综合 | 天堂v在线观看 | 亚洲av无码乱码在线观看性色 | 狠狠v欧美v日韩v亚洲ⅴ | 超碰97国产在线 | 日韩欧美毛片 | 黄色a一级视频 | 最近中文字幕在线mv视频在线 | 国产美女被遭强高潮免费网站 | 欧美日韩精品在线视频 | 亚洲视频中文字幕在线观看 | 窝窝视频在线观看 | 激情综合文学 | 中文字幕在线观看网 | 国产黄色高清 | 91黄色免费视频 | 亚洲综合视频网 | 神马久久精品 | 在线看你懂 | 国产精品美女久久久久图片 | 少妇闺蜜换浪荡h肉辣文 | 欧美孕交视频 | 综合色亚洲| 天天操天天爽天天干 | 欧美乱妇狂野欧美在线视频 | 林天顾悦瑶笔趣阁 | 国产欧美日韩三级 | 麻豆免费视频网站 | 女性生殖扒开酷刑vk | 麻豆视频一区二区三区 | 色综合天天综合网天天看片 | 91精品久久久久久久 | 中文字幕第7页 | 欧美成人一级视频 | 日本老年老熟无码 | 久久久久久久久97 | 久久久久亚洲色欲AV无码网站 | 欧洲一区二区 | 老司机午夜av | 国产剧情av引诱维修工 | 午夜寂寞福利 | 女生隐私免费看 | 欧美日韩一区二区三区在线电影 | 日韩欧美第一页 |