查看maven项目的依赖关系 mvn dependency:tree

Posted 蝈蝈俊的技术心得

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查看maven项目的依赖关系 mvn dependency:tree相关的知识,希望对你有一定的参考价值。

查看maven项目的依赖,我们可以用下面命令:

mvn dependency:tree
以Dubbo的 dubbo-demo-provider 为例,我们输入这个命令可以获得下面信息:

mvn dependency:tree
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.alibaba:dubbo-demo-provider:jar:2.5.4-SNAPSHOT
[WARNING] ‘build.plugins.plugin.version‘ for org.apache.maven.plugins:maven-surefire-plugin is missing. @ com.alibaba:dubbo-parent:2.5.4-SNAPSHOT, /Users/ghj1976/project/github/alibaba/dubbo/pom.xml, line 379, column 12
[WARNING] ‘build.plugins.plugin.version‘ for org.apache.maven.plugins:maven-jar-plugin is missing. @ com.alibaba:dubbo-parent:2.5.4-SNAPSHOT, /Users/ghj1976/project/github/alibaba/dubbo/pom.xml, line 365, column 12
[WARNING] ‘build.plugins.plugin.version‘ for org.apache.maven.plugins:maven-deploy-plugin is missing. @ com.alibaba:dubbo-parent:2.5.4-SNAPSHOT, /Users/ghj1976/project/github/alibaba/dubbo/pom.xml, line 449, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building dubbo-demo-provider 2.5.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ dubbo-demo-provider ---
[INFO] com.alibaba:dubbo-demo-provider:jar:2.5.4-SNAPSHOT
[INFO] +- com.alibaba:dubbo-demo-api:jar:2.5.4-SNAPSHOT:compile
[INFO] +- com.alibaba:dubbo:jar:2.5.4-SNAPSHOT:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring:jar:2.5.6.SEC03:compile
[INFO] +- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] +- org.jboss.netty:netty:jar:3.2.5.Final:compile
[INFO] +- org.apache.mina:mina-core:jar:1.1.7:compile
[INFO] +- org.glassfish.grizzly:grizzly-core:jar:2.1.4:compile
[INFO] |  +- org.glassfish.grizzly:grizzly-framework:jar:2.1.4:compile
[INFO] |  |  \- org.glassfish.gmbal:gmbal-api-only:jar:3.0.0-b023:compile
[INFO] |  |     \- org.glassfish.external:management-api:jar:3.0.0-b012:compile
[INFO] |  +- org.glassfish.grizzly:grizzly-portunif:jar:2.1.4:compile
[INFO] |  \- org.glassfish.grizzly:grizzly-rcm:jar:2.1.4:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.1.2:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.4:compile
[INFO] +- com.alibaba:fastjson:jar:1.1.39:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.4.1:compile
[INFO] |  +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] |  \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- org.apache.bsf:bsf-api:jar:3.1:compile
[INFO] +- org.apache.zookeeper:zookeeper:jar:3.3.3:compile
[INFO] |  \- jline:jline:jar:0.9.94:compile
[INFO] +- com.github.sgroschupf:zkclient:jar:0.1:compile
[INFO] +- com.netflix.curator:curator-framework:jar:1.1.16:compile
[INFO] |  +- com.netflix.curator:curator-client:jar:1.1.16:compile
[INFO] |  \- com.google.guava:guava:jar:11.0.1:compile
[INFO] |     \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- com.googlecode.xmemcached:xmemcached:jar:1.3.6:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.6.1:compile
[INFO] |  +- org.apache.cxf:cxf-api:jar:2.6.1:compile
[INFO] |  |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.1.2:runtime
[INFO] |  |  |  \- org.codehaus.woodstox:stax2-api:jar:3.1.1:runtime
[INFO] |  |  +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.2:compile
[INFO] |  |  +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO] |  |  \- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO] |  +- org.apache.cxf:cxf-rt-core:jar:2.6.1:compile
[INFO] |  |  \- com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile
[INFO] |  \- org.apache.cxf:cxf-rt-bindings-soap:jar:2.6.1:compile
[INFO] |     \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.6.1:compile
[INFO] +- org.apache.cxf:cxf-rt-transports-http:jar:2.6.1:compile
[INFO] +- org.apache.thrift:libthrift:jar:0.8.0:compile
[INFO] |  \- commons-lang:commons-lang:jar:2.5:compile
[INFO] +- com.caucho:hessian:jar:4.0.7:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO] |  +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
[INFO] |  \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.2:compile
[INFO] +- redis.clients:jedis:jar:2.1.0:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.5.5:compile
[INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] +- org.hibernate:hibernate-validator:jar:4.2.0.Final:compile
[INFO] +- javax.cache:cache-api:jar:0.4:compile
[INFO] +- junit:junit:jar:4.10:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- org.easymock:easymock:jar:3.0:test
[INFO] |  +- cglib:cglib-nodep:jar:2.2:test
[INFO] |  \- org.objenesis:objenesis:jar:1.2:test
[INFO] +- org.easymock:easymockclassextension:jar:3.0:test
[INFO] \- com.googlecode.jmockit:jmockit:jar:0.999.8:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.057 s
[INFO] Finished at: 2016-03-29T15:41:31+08:00
[INFO] Final Memory: 12M/309M
[INFO] ------------------------------------------------------------------------

 

参考资料:

使用maven命令来分析jar包之间的依赖关系
http://outofmemory.cn/code-snippet/10914/maven-command-dependency

以上是关于查看maven项目的依赖关系 mvn dependency:tree的主要内容,如果未能解决你的问题,请参考以下文章

Maven命令行手动添加依赖 mvn dependency:get命令的使用

mvn clean install对idea中项目结构的影响

Maven类包冲突终极三大解决技巧 mvn dependency:tree

如何配置maven pom文件来解决jar包冲突

Maven导出Project依赖的jar包

AndroidStudio 查看项目依赖关系