国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

maven獲取所有依賴項

這篇具有很好參考價值的文章主要介紹了maven獲取所有依賴項。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

轉(zhuǎn)載maven的mvn dependency依賴分析和常用命令介紹 - 簡書

maven的mvn dependency依賴分析和常用命令介紹

在項目開發(fā)過程中,我們經(jīng)常會有分析項目依賴的需要,查找jar依賴路徑,查找jar沖突等等。這時候,dependency命令會非常的有用,在此我們介紹下關于maven的dependency命令的一些用法。

1.?mvn dependency:list?---- 列出項目的所有jar包

mvn dependency:list -Dverbose
該命令可以列出項目依賴的所有jar包,-Dverbose參數(shù)會把被忽略的jar,即相同jar包的不同版本引入也列出來。
輸出示例:

[INFO]    org.springframework:spring-aop:jar:5.0.6.RELEASE:compile
[INFO]    org.hibernate.validator:hibernate-validator:jar:6.0.9.Final:compile
[INFO]    com.fasterxml.jackson.core:jackson-core:jar:2.9.5:compile
[INFO]    com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.5:compile
[INFO]    org.springframework:spring-expression:jar:5.0.6.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter:jar:2.0.2.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-logging:jar:2.0.2.RELEASE:compile
[INFO]    org.yaml:snakeyaml:jar:1.19:runtime
[INFO]    org.springframework.boot:spring-boot:jar:2.0.2.RELEASE:compile
[INFO]    junit:junit:jar:3.8.1:test

?

2.?mvn dependency:tree?---- 列出項目的包依賴樹

mvn dependency:tree -Dverbose
這個命令跟上一個命令的區(qū)別就是,這個命令的依賴,輸出來是個樹,更方便看依賴關系。
輸出示例:

[INFO] \- org.springframework.boot:spring-boot-starter-web:jar:2.0.2.RELEASE:compile
[INFO]    +- org.springframework.boot:spring-boot-starter:jar:2.0.2.RELEASE:compile
[INFO]    |  \- org.springframework:spring-core:jar:5.0.6.RELEASE:compile
[INFO]    |     \- org.springframework:spring-jcl:jar:5.0.6.RELEASE:compile
[INFO]    +- org.springframework:spring-web:jar:5.0.6.RELEASE:compile
[INFO]    |  \- org.springframework:spring-beans:jar:5.0.6.RELEASE:compile
[INFO]    \- org.springframework:spring-webmvc:jar:5.0.6.RELEASE:compile
[INFO]       +- org.springframework:spring-aop:jar:5.0.6.RELEASE:compile
[INFO]       +- org.springframework:spring-context:jar:5.0.6.RELEASE:compile
[INFO]       \- org.springframework:spring-expression:jar:5.0.6.RELEASE:compile

dependency:tree有幾個比較重要的參數(shù),非常有用:

  • includes
    • 說明:該參數(shù)可以列出指定要求的jar,其他的忽略
    • 示例:-Dincludes=velocity:velocity,只列出velocity的依賴關系
    • 參數(shù)值:[groupId]:[artifactId]:[type]:[version],參數(shù)格式就是這樣的,沒有的值可以留空,舉例-Dincludes=:spring-aop-Dincludes=:::5.0.6.RELEASE,-Dincludes=org.springframework
    • 通配符:在參數(shù)中可以使用通配符,例如org.apache.*,?:::*-SNAPSHOT
    • 多個參數(shù)值:參數(shù)后面可以跟多個參數(shù)值,以英文逗號分隔,舉例-Dincludes=org.apache.maven*,org.codehaus.plexus
  • excludes
    • 說明:該參數(shù)的用法跟includes是一樣的,不過這個參數(shù)的作用是排除指定的jar

示例:查看包沖突

比如我們查看一下commons-collections包的沖突
命令:
mvn dependency:tree -Dverbose -Dincludes=commons-collections
輸出:

[INFO] [dependency:tree]
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
[INFO] +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile
[INFO] |  \- commons-validator:commons-validator:jar:1.2.0:compile
[INFO] |     \- commons-digester:commons-digester:jar:1.6:compile
[INFO] |        \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.0)
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
[INFO]    \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
[INFO]       \- commons-collections:commons-collections:jar:2.0:compile

我們可以看到,2.1版本的jar被忽略掉了,因為maven是根據(jù)路徑最近原則來解析依賴,2.0版本路徑更短,所以2.0版本被引入,2.1版本路徑比2.0要長,所以被忽略。
使用這個命令可以輕松的查看包的引入路徑,包的沖突情況。
此處一定不要省略-Dverbose參數(shù),要不然是不會顯示被忽略的包

3.?dependency:analyze-only?---- 分析依賴

dependency:analyze-only命令可以分析整個項目,并且找出項目中依賴有如下情況的:

  • 聲明了并且使用了的依賴
  • 沒有聲明但是使用了的依賴
  • 聲明了但是沒有使用的依賴

輸出示例:

[INFO] Used declared dependencies found:
[INFO]    cn.hutool:hutool-all:jar:4.3.1:compile
[INFO]    com.google.guava:guava:jar:27.0.1-jre:compile
[WARNING] Used undeclared dependencies found:
[WARNING]    org.slf4j:slf4j-api:jar:1.7.25:compile
[WARNING]    org.springframework:spring-context:jar:4.3.22.RELEASE:compile
[WARNING]    org.springframework.boot:spring-boot-autoconfigure:jar:1.5.19.RELEASE:compile
[WARNING]    org.springframework.boot:spring-boot:jar:1.5.19.RELEASE:compile
[WARNING]    org.springframework:spring-beans:jar:4.3.22.RELEASE:compile
[WARNING]    junit:junit:jar:4.12:test
[WARNING] Unused declared dependencies found:
[WARNING]    org.springframework.boot:spring-boot-starter-test:jar:1.5.19.RELEASE:test
[WARNING]    com.h2database:h2:jar:1.4.197:test
[WARNING]    org.springframework.boot:spring-boot-starter:jar:1.5.19.RELEASE:compile
[WARNING]    com.fasterxml.jackson.core:jackson-databind:jar:2.8.11.3:compile
[WARNING]    org.projectlombok:lombok:jar:1.16.22:compile
[WARNING]    com.alibaba:fastjson:jar:1.2.55:compile

需要注意的是,如果你要查看聲明了并且使用了的依賴,必須加上參數(shù)-Dverbose

4.?dependency:analyze-duplicate?---- 分析<dependencies/> 和<dependencyManagement/>

這個命令會查找<dependencies/> 和 <dependencyManagement/>中重復聲明的依賴

5.?dependency:list-repositories?---- 列出所有的遠程repositories

命令:
mvn dependency:list-repositories

輸出:

[INFO]        id: sonatype-nexus-snapshots
      url: https://oss.sonatype.org/content/repositories/snapshots
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

[INFO]        id: apache.snapshots
      url: https://repository.apache.org/snapshots
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

[INFO]        id: central
      url: https://repo.maven.apache.org/maven2
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => daily]

6.?dependency:purge-local-repository?---- 清理本地repository

這個命令的會首先解析整個項目的依賴,然后從本地repository中清理這些依賴,重新從遠程repository下載。文章來源地址http://www.zghlxwxcb.cn/news/detail-444361.html

  • 直接依賴
    有一點要說清楚,這個命令默認的對所有的依賴項進行操作。所以它會在清除操作之前,下載某些缺失的依賴來收集完整的依賴樹信息。為了避免這些預下載的操作,你可以設置參數(shù)-DactTransitively=false,僅對項目的直接依賴進行操作。
  • 指定/排除依賴
    你也可以有針對性的只操作某些包,需要添加參數(shù)-Dincludes,明確的聲明包,這個是可以傳多個值的,用英文逗號分隔,舉例:dependency:purge-local-repository -Dincludes=org.slf4j:slf4j-api,org.slf4j:log4j-over-slf4j-Dexcludes也是一樣的道理,只不過是排除某些依賴。
  • 自定義清理
    如果你想清理不在本項目中的依賴,也可以使用這個,不過參數(shù)是不一樣的。mvn dependency:purge-local-repository -DmanualIncludes=org.apache:apache,參數(shù)-DmanualInclude可以讓你清理不在本項目中的依賴,但是不會重新解析依賴了,因為本項目不需要這些依賴。這個對清理parent pom,導入的pom,maven插件非常有用。

到了這里,關于maven獲取所有依賴項的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • Maven本地配置獲取nexus私服的依賴

    Maven本地配置獲取nexus私服的依賴

    Nexus-在項目中使用Maven私服,Deploy到私服、上傳第三方jar包、在項目中使用私服jar包: Nexus-在項目中使用Maven私服,Deploy到私服、上傳第三方jar包、在項目中使用私服jar包_nexus maven-releases 允許deploy-CSDN博客 在上面講的是在需要拉取私服依賴的項目中的pom中配置repository的方式去

    2024年02月05日
    瀏覽(19)
  • Idea怎么配置Maven才能優(yōu)先從本地倉庫獲取依賴

    Idea怎么配置Maven才能優(yōu)先從本地倉庫獲取依賴

    網(wǎng)上的方法 : 在設置中搜索 Runner ,在VM Option中設置參數(shù) -DarchetypeCatalog=internal 刪除 解壓后的依賴包中的 _remote.repositories m2e-lastUpdated.properties *.lastUpdated 文件。 上邊都沒有效果 最終的解決方法,修改maven配置文件settings.xml 主要兩個方面 第一:修改本地倉庫的地址,這個是自己

    2024年02月02日
    瀏覽(23)
  • 數(shù)據(jù)依賴和控制依賴 Data Dependence and Contol Dependence

    數(shù)據(jù)依賴和控制依賴 Data Dependence and Contol Dependence

    數(shù)據(jù)依賴和控制依賴分析是許多優(yōu)化的重要工具,比如指令調(diào)度、激進死代碼刪除(ADCE)等。 數(shù)據(jù)依賴是數(shù)據(jù)流之間的一種依賴,主要包括四種(參考鯨書)。 1.流依賴/真依賴( flow/true dependence ):S1定義了一個值,隨后S2使用了這個值。記 S 1 ? δ f ? S 2 S1 delta^f S2 S 1

    2024年02月09日
    瀏覽(22)
  • Maven多模塊管理(轉(zhuǎn)載)

    注意:父模塊需設定打包方式為pom https://cloud.tencent.com/developer/article/1667275 在父類maven中加入,不會繼承給子類,只能規(guī)定子類的依賴版本,子類加入dependence后無需寫入 在一個項目中存在多個模塊時,可以通過聚合一鍵打包、安裝所有的模塊。只需要在父maven中加入modules標簽

    2024年02月07日
    瀏覽(25)
  • 什么是依賴注入(Dependency Injection)?

    依賴注入(Dependency Injection,簡稱DI)是一種設計模式,用于實現(xiàn)類之間的解耦和依賴關系的管理。它通過將依賴關系的創(chuàng)建和維護責任轉(zhuǎn)移到外部容器中,使得類不需要自己實例化依賴對象,而是由外部容器動態(tài)地注入依賴。 傳統(tǒng)的對象創(chuàng)建方式往往由類自身負責創(chuàng)建和管

    2024年02月15日
    瀏覽(17)
  • 【Python開發(fā)】FastAPI 07:Depends 依賴注入

    【Python開發(fā)】FastAPI 07:Depends 依賴注入

    在 FastAPI 中, Depends 是一個依賴注入系統(tǒng),用于注入應用程序中所需的依賴項,通過 Depends ,我們可以輕松地將依賴項注入到 FastAPI 路由函數(shù)中。簡單來說,Depends 依賴注入的目的就是將代碼重復最??! 目錄 1?Depends 使用 1.1?依賴注入介紹 1.2 demo 1.3?OpenAPI 集成 2 不同依賴項

    2024年02月08日
    瀏覽(20)
  • vue-package.json中的dependencies(生產(chǎn)依賴)和devDependencies(開發(fā)依賴)

    ?以下所有安裝命令都會對node_modules生效,即安裝都會安裝到node_modules中,刪除也會中從node_modules中刪除 1、不會添加到package.json中 2、會添加到package.json的dependencies中 ,build時會打進去, 3、會添加到package.json的devDependencies中?? 參考package.json中的dependencies(生產(chǎn)依賴)和devD

    2024年02月13日
    瀏覽(20)
  • 【VC++開發(fā)必備神器 -- Dependencies,查看依賴庫DLL,支持win10,比depends更好用】

    【VC++開發(fā)必備神器 -- Dependencies,查看依賴庫DLL,支持win10,比depends更好用】

    軟件之Dependencies,不同于depends 1、微軟官方有提供depends,可以查看exe文件的依賴庫,僅適用于winxp/win7/win8,但是不能用于win10,會卡死報錯. 官網(wǎng)下載:Dependency Walker (depends.exe) Home Page 左上角第一個窗口是Dll信息窗口,顯示程序所需的Dll模塊。 如何使用Depends.exe查看dll動態(tài)鏈

    2024年02月05日
    瀏覽(15)
  • IDEA庫(Libraries)和模塊依賴(Dependencies)詳解

    IDEA庫(Libraries)和模塊依賴(Dependencies)詳解

    庫是模塊可以依賴的已編譯代碼的集合。在IntelliJ IDEA中,可以在三個級別上定義庫: 全局 (可用于許多項目), 項目 (可用于 項目 中的所有模塊)和 模塊 (可用于一個模塊) 簡單來說,IDEA中的庫(Libraries)就是用來存放外部jar包,我們的項目或模塊需要某些jar包時,

    2024年01月25日
    瀏覽(19)
  • Angular 17+ 高級教程 – Dependency Injection 依賴注入

    Angular 17+ 高級教程 – Dependency Injection 依賴注入

    本來是想先介紹 Angular Component 的,但 Component 里面會涉及到一些 Dependency Injection (簡稱 DI) 的概念,所以還是先介紹 DI 吧。 溫馨提醒:如果你對 JS class、prototype 不太熟悉的話,建議你先看這篇?JavaScript – 理解 Object, Class, This, Prototype, Function, Mixins ? 首先我們有一個 class Ser

    2024年03月09日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包