maven依赖版本的继承
inheritance of maven dependency version
在我的 pom.xml 中,我定义了这样的依赖项
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
</dependencies>
未明确指定此依赖项的版本。但是,它可以工作,而且我有 1.8.2.RELEASE
版本。
我知道可能是因为继承,通过mvn help:effective-pom
,我可以看到spring-data-jpa
的有效版本号。但是我检查了父 pom 并没有找到 spring-data-jpa
版本号的任何定义。
我怎么知道在哪个 POM 文件 maven 在 pom 继承树上获取了 spring-data-jpa
的版本?有没有这个的maven命令?
mvn dependecy:tree 输出是这样的:
[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
但是这个输出中没有相关的 POM 文件,所以我不知道版本是从哪个 POM 文件推导出来的。
运行: mvn dependency:tree
在命令行上,你会在树中看到所有的依赖关系,所以你知道依赖关系来自哪里
看起来像:
[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
有关依赖插件的更多信息,请参阅 documentation
在我的 pom.xml 中,我定义了这样的依赖项
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
</dependencies>
未明确指定此依赖项的版本。但是,它可以工作,而且我有 1.8.2.RELEASE
版本。
我知道可能是因为继承,通过mvn help:effective-pom
,我可以看到spring-data-jpa
的有效版本号。但是我检查了父 pom 并没有找到 spring-data-jpa
版本号的任何定义。
我怎么知道在哪个 POM 文件 maven 在 pom 继承树上获取了 spring-data-jpa
的版本?有没有这个的maven命令?
mvn dependecy:tree 输出是这样的:
[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
但是这个输出中没有相关的 POM 文件,所以我不知道版本是从哪个 POM 文件推导出来的。
运行: mvn dependency:tree
在命令行上,你会在树中看到所有的依赖关系,所以你知道依赖关系来自哪里
看起来像:
[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
有关依赖插件的更多信息,请参阅 documentation