Maven Display project dependency
By:Roy.LiuLast updated:2019-08-17
In Maven, you can use mvn dependency:tree to display the project dependencies in tree format.
1. Maven Project
Review a simple Maven project, declared Spring and logback dependencies.
pom.xml
<properties> <spring.version>4.1.6.RELEASE</spring.version> <logback.version>1.1.3</logback.version> <jcl.slf4j.version>1.7.12</jcl.slf4j.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${jcl.slf4j.version}</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback.version}</version> </dependency> </dependencies>
2. mvn dependency:tree
Example to display above project dependencies.
Terminal
$ mvn dependency:tree [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building {Project Name} [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ spring-mvc-logback --- [INFO] com.mkyong.common:spring-mvc-logback:war:1.0-SNAPSHOT [INFO] +- org.springframework:spring-core:jar:4.1.6.RELEASE:compile [INFO] +- org.springframework:spring-webmvc:jar:4.1.6.RELEASE:compile [INFO] | +- org.springframework:spring-beans:jar:4.1.6.RELEASE:compile [INFO] | +- org.springframework:spring-context:jar:4.1.6.RELEASE:compile [INFO] | | \- org.springframework:spring-aop:jar:4.1.6.RELEASE:compile [INFO] | | \- aopalliance:aopalliance:jar:1.0:compile [INFO] | +- org.springframework:spring-expression:jar:4.1.6.RELEASE:compile [INFO] | \- org.springframework:spring-web:jar:4.1.6.RELEASE:compile [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile [INFO] | \- org.slf4j:slf4j-api:jar:1.7.12:compile [INFO] +- ch.qos.logback:logback-classic:jar:1.1.3:compile [INFO] | \- ch.qos.logback:logback-core:jar:1.1.3:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.937 s [INFO] Finished at: 2015-06-19T19:17:54+08:00 [INFO] Final Memory: 13M/308M [INFO] ------------------------------------------------------------------------
Done.
Note
Visit Maven Dependency Plugin for more usages and examples.
Visit Maven Dependency Plugin for more usages and examples.
From:一号门
Previous:Java Convert String to int
COMMENTS