1

In my pom.xml I have defined a dependency like this

  <dependencies>
     <dependency>
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-jpa</artifactId>
    </dependency>
  </dependencies>

without specifying explicitly the version of this dependency. However, it works and I've got the version 1.8.2.RELEASE.

I know that it may be because of the inheritance and by mvn help:effective-pom, I can see the effective version number of spring-data-jpa. But I checked the parent pom and I didn't find any definition of the version number for spring-data-jpa.

How can I know in which POM file maven has picked up the version for spring-data-jpa when going up the pom inheritance tree? Is there a maven command for this?

mvn dependecy:tree output is like this:

[INFO] +- org.hibernate:hibernate-envers:jar:4.2.18.Final:provided
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.8.2.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-commons:jar:1.10.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-orm:jar:4.0.9.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:4.0.9.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.1.7.RELEASE:compile
[INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework:spring-tx:jar:4.0.9.RELEASE:compile
[INFO] |  +- org.aspectj:aspectjrt:jar:1.8.6:compile
[INFO] |  \- org.slf4j:jcl-over-slf4j:jar:1.7.12:runtime
[INFO] +- org.springframework.data:spring-data-envers:jar:1.0.8.RELEASE:compile
[INFO] |  \- joda-time:joda-time:jar:2.8.2:compile

But there is no related POM file in this output so I cannot know from which POM file the version is deduced.

Gab是好人
  • 1,976
  • 1
  • 25
  • 39

1 Answers1

0

run: mvn dependency:tree on command line and you will see all dependencies in a tree, so you know where the dependency comes from

it Looks like:

[INFO] [dependency:tree]
2.[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
3.[INFO] +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile
4.[INFO] |  \- commons-validator:commons-validator:jar:1.2.0:compile
5.[INFO] |     \- commons-digester:commons-digester:jar:1.6:compile
6.[INFO] |        \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.0)
7.[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
8.[INFO]    \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
9.[INFO]       \- commons-collections:commons-collections:jar:2.0:compile

For more informations about the dependency plugin see the documentation

Jens
  • 67,715
  • 15
  • 98
  • 113
  • Thanks, but I cannot see which POM file has defined the version (1.8.2.RELEASE) for `spring-data-jpa`. – Gab是好人 Aug 16 '17 at 09:37
  • @Gab是好人 Can you Show the Output of the comment as an edit in your question? Do oyu have a spring pom as parent pom? – Jens Aug 16 '17 at 09:38
  • I have a spring pom as parent pom but I didn't find any definition of the version of `spring-data-jpa` in it. – Gab是好人 Aug 16 '17 at 09:50
  • @Gab是好人 it Looks like that is directly dinied in your pom. Can you share it please – Jens Aug 16 '17 at 09:51
  • Hello, finally, I've found that it is because of an "import" scoped dependency in the dependencyManagement section of a parent POM. But still, I have not found any maven command that can tell me where comes a dependency's version automatically. – Gab是好人 Aug 17 '17 at 07:31