如果是用命令行,可進入項目所在目錄,然后輸入: mvn dependency:tree ,來查看jar包依賴關系。
另外還可以在eclipse操作,如下圖所示:
點擊run后,開始輸出JAR包依賴樹。
我在執行這步的時候報了下面的異常:
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.graph.DependencyNode
在網上搜了好多地方都沒有類似的錯誤,后來參考了一些帖子,懷疑是maven-dependency-plugin的版本問題,然后就把插件的版本改為2.10了:
修改前:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>.........
修改后:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>.........
然后再次執行上面所說的命令,執行成功:
......
[INFO] +- com.csair:extra-api:jar:1.0.1-20170228:compile
[INFO] +- com.csair.engine.fq:fq-domain:jar:0.7.0-SNAPSHOT:compile
[INFO] | +- org.springframework:spring-context:jar:3.0.7.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:3.0.7.RELEASE:compile
[INFO] | | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | | +- org.springframework:spring-beans:jar:3.0.7.RELEASE:compile
[INFO] | | +- org.springframework:spring-core:jar:3.0.7.RELEASE:compile
[INFO] | | +- org.springframework:spring-expression:jar:3.0.7.RELEASE:compile
[INFO] | | \- org.springframework:spring-asm:jar:3.0.7.RELEASE:compile
[INFO] | +- com.sun.xml.bind:jaxb-facets:jar:0.9.0:compile
[INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile
[INFO] | \- javax.xml.bind:jaxb-api:jar:2.1:compile
[INFO] | \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] +- com.csair.engine.fq:fdc-client:jar:1.1.2:compile
[INFO] | +- com.csair.engine.fq:fdc-domain:jar:1.0.1:compile
[INFO] | | \- com.csair.engine.fq:fq-domain-backport:jar:0.2.1:compile
[INFO] | | \- commons-io:commons-io:jar:2.2:compile
[INFO] | \- org.apache.mina:mina-core:jar:2.0.7:compile
[INFO] +- freemarker:freemarker:jar:2.3.8:compile
[INFO] +- org.apache.velocity:velocity:jar:1.7:compile
[INFO] \- org.apache.velocity:velocity-tools:jar:2.0:compile
[INFO] +- commons-digester:commons-digester:jar:1.8:compile
[INFO] +- commons-chain:commons-chain:jar:1.1:compile
[INFO] +- commons-validator:commons-validator:jar:1.3.1:compile
[INFO] +- oro:oro:jar:2.0.8:compile
[INFO] +- sslext:sslext:jar:1.2-0:compile
[INFO] +- org.apache.struts:struts-core:jar:1.3.8:compile
[INFO] | \- antlr:antlr:jar:2.7.2:compile
[INFO] +- org.apache.struts:struts-taglib:jar:1.3.8:compile
[INFO] \- org.apache.struts:struts-tiles:jar:1.3.8:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
........
其中“+-”符號表示該包后面還有其它依賴包,“\-”表示該包后面不再依賴其它jar包了。
除此以外,還有個更加簡便的方法,就是在eclipse里面用Maven POM Editor打開pom.xml文件:
如有錯誤,歡迎指出交流。