本文为博主原创,转载请注明出处:
1. mvn dependency:list
---- 列出项目的所有jar包
mvn dependency:list -Dverbose
该命令可以列出项目依赖的所有jar包,-Dverbose参数会把被忽略的jar,即相同jar包的不同版本引入也列出来。
输出示例:
2.mvn dependency:tree
---- 列出项目的包依赖树
mvn dependency:tree -Dverbose
这个命令跟上一个命令的区别就是,这个命令的依赖,输出来是个树,更方便看依赖关系。
输出示例:
2.1 查看某一个包的依赖树
mvn dependency:tree -Dverbose -Dincludes=commons-collections
3. mvn dependency:analyze
---- 分析依赖并优化
mvn dependency:analyze -Dverbose
mvn dependency:analyze命令可以分析当前项目的依赖,我们可以根据这个结果删除多余的依赖。
其执行的结果如下:
[INFO] Used declared dependencies found: [INFO] com.alibaba:fastjson:jar:1.2.73:compile [INFO] org.hibernate:hibernate-validator:jar:5.3.6.Final:compile [INFO] io.springfox:springfox-swagger2:jar:2.7.0:compile [INFO] junit:junit:jar:4.12:test [INFO] joda-time:joda-time:jar:2.9.9:compile [WARNING] Used undeclared dependencies found: [WARNING] io.springfox:springfox-spi:jar:2.7.0:compile [WARNING] com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile [WARNING] io.springfox:springfox-core:jar:2.7.0:compile [WARNING] org.apache.commons:commons-lang3:jar:3.5:compile [WARNING] org.slf4j:slf4j-api:jar:1.7.25:compile [WARNING] org.springframework:spring-web:jar:4.3.16.RELEASE:compile [WARNING] javax.validation:validation-api:jar:1.1.0.Final:compile [WARNING] org.jasig.cas.client:cas-client-core:jar:3.3.3:compile [WARNING] io.springfox:springfox-spring-web:jar:2.7.0:compile [WARNING] net.logstash.logback:logstash-logback-encoder:jar:4.11:compile [WARNING] org.springframework:spring-beans:jar:4.3.16.RELEASE:compile [WARNING] Unused declared dependencies found: [WARNING] org.apache.tomcat.embed:tomcat-embed-jasper:jar:8.5.29:provided [WARNING] org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.12.RELEASE:provided [WARNING] org.projectlombok:lombok:jar:1.18.12:provided [WARNING] org.springframework:spring-test:jar:4.3.16.RELEASE:test [WARNING] org.springframework.boot:spring-boot-loader:jar:1.5.12.RELEASE:provided [WARNING] io.springfox:springfox-swagger-ui:jar:2.7.0:compile [INFO] ------------------------------------------------------------------------
mvn dependency:analyze 的执行结果会将 pom 的依赖解析成三部分: Used declared dependencies、Used undeclared dependencies、Unused declared dependencies 三部分,可以根据 Unused declared dependencies 中的依赖进行优化;从pom中进行相应的删除,从而减少依赖;
Used undeclared dependencies: 表示项目中使用到的,但是没有显示声明的依赖
Unused declared dependencies: 表示项目中未使用的,但显示声明的依赖;可以进行删除
Used declared dependencies:表示项目中使用且声明的依赖
4. mvn dependency:analyze-duplicate
---- 分析是否存在重复配置的依赖
mvn dependency:analyze-duplicate
分析 pom 中是否存在重复配置的依赖:其执行结果如下:
标签:compile,WARNING,jar,maven,dependency,pom,常用命令,org,mvn From: https://www.cnblogs.com/zjdxr-up/p/17118221.html