Pivotal Knowledge Base

Follow

How to list implicit and explicit dependencies on your spring applications using maven

Environment 

Spring projects: All

Maven: 3.0+

Overview

There are a lot of Spring Projects, and it's hard to keep a track of the dependencies within dependency that you specify in your pom.xml. For example, you used jar A, and this uses a jar A1 then you also used jar B, and this uses jar B1. This article explains an easier way to keep track of dependencies using the maven tool so that you can list all the dependencies.

Let us take for example this spring application. This article also addresses questions like which version of spring-core, spring-data, and Cassandra driver does this project uses.

If you look into the project's pom.xml, it's not specified there because it is implicitly used by dependency jars you specified in your pom.

Here's how you can get an answer to this question.

1. Using your maven project, make sure the pom.xml is syntax error free. You should be able to run "mvn clean" without any problems. 

2. Run "mvn dependency:tree -Dverbose.This would display all your dependencies on your project in a tree form so it should be able to see their corresponding versions as well. Below is a snippet of the command.

Answering our question above: Which version of spring-core, spring-data, and Cassandra driver does this project use? Looking at the tree below, We can see its using spring-core:jar:4.3.7.RELEASEspring-data-commons:jar:1.13.1.RELEASE, cassandra-driver-core:jar:3.1.4

$ mvn dependency:tree -Dverbose

[INFO] ------------------------------------------------------------------------
[INFO] Building spring-cloud-starter-stream-sink-cassandra 1.2.1.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.spring.io/libs-milestone-local/org/springframework/cloud/stream/app/plugin/spring-cloud-stream-app-maven-plugin/maven-metadata.xml
Downloading: http://repo.spring.io/libs-snapshot-local/org/springframework/cloud/stream/app/plugin/spring-cloud-stream-app-maven-plugin/maven-metadata.xml
Downloaded: http://repo.spring.io/libs-milestone-local/org/springframework/cloud/stream/app/plugin/spring-cloud-stream-app-maven-plugin/maven-metadata.xml (537 B at 0.9 KB/sec)
Downloaded: http://repo.spring.io/libs-snapshot-local/org/springframework/cloud/stream/app/plugin/spring-cloud-stream-app-maven-plugin/maven-metadata.xml (893 B at 1.2 KB/sec)
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ spring-cloud-starter-stream-sink-cassandra ---
[INFO] org.springframework.cloud.stream.app:spring-cloud-starter-stream-sink-cassandra:jar:1.2.1.BUILD-SNAPSHOT
[INFO] +- org.springframework.integration:spring-integration-cassandra:jar:0.5.0.RELEASE:compile
[INFO] | +- org.springframework.integration:spring-integration-core:jar:4.3.8.RELEASE:compile (version managed from 4.1.5.RELEASE)
[INFO] | | +- org.springframework:spring-core:jar:4.3.7.RELEASE:compile
[INFO] | | | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- org.springframework:spring-context:jar:4.3.7.RELEASE:compile
[INFO] | | | +- (org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | | \- (org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-messaging:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework.retry:spring-retry:jar:1.2.0.RELEASE:compile - version managed from 1.1.3.RELEASE; omitted for duplicate)
[INFO] | \- org.springframework.data:spring-data-cassandra:jar:1.5.1.RELEASE:compile (version managed from 1.2.0.RELEASE)
[INFO] | +- org.springframework.data:spring-cql:jar:1.5.1.RELEASE:compile
[INFO] | | +- (org.springframework:spring-context:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (com.datastax.cassandra:cassandra-driver-core:jar:3.1.4:compile - version managed from 3.1.3; omitted for duplicate)
[INFO] | | +- com.google.guava:guava:jar:18.0:compile (version managed from 19.0)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.7; omitted for duplicate)
[INFO] | | \- (org.slf4j:jcl-over-slf4j:jar:1.7.24:runtime - omitted for duplicate)
[INFO] | +- org.springframework:spring-expression:jar:4.3.7.RELEASE:compile
[INFO] | | \- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile
[INFO] | | +- (org.springframework:spring-core:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.24:compile - version managed from 1.7.7; omitted for duplicate)

 

 

Comments

Powered by Zendesk