如何查找从BOM表导入的Maven依赖版本声明 [英] How to find a Maven dependency version declaration imported from a BOM

查看:315
本文介绍了如何查找从BOM表导入的Maven依赖版本声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多模块父POM声明以下BOM导入:

A multi-module parent POM declares the following BOM import:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.spring.platform</groupId>
      <artifactId>platform-bom</artifactId>
      <version>${spring.io.platform.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>

然后模块POM声明一个Hibernate依赖项:

Then a module POM declares a Hibernate dependency:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
</dependency>

如何使用Maven命令行或IntelliJ找出定义了有效Hibernate版本的地方?

How do I find out with Maven command line or IntelliJ where the effective Hibernate version is defined?

针对我的模块运行mvn dependency:tree会产生以下结果:

Running mvn dependency:tree against my module yields:

...
[INFO] +- org.hibernate:hibernate-core:jar:4.3.11.Final:compile
...

并不完全有用,因为它看起来与我自己管理Hibernate版本没有什么不同.如果您必须手动执行此操作

which is not exactly helpful because it looks no different than if I managed the Hibernate version myself. If you have to do this manually you

  • platform-bom-2.0.3.RELEASE.pom开始,搜索Hibernate->无需任何操作
  • 转到其父级spring-boot-starter-parent-1.3.3.RELEASE.pom,搜索Hibernate->无需任何操作
  • 转到父级spring-boot-dependencies-1.3.3.RELEASE.pom,搜索Hibernate->最后...
  • start at platform-bom-2.0.3.RELEASE.pom, search for Hibernate -> nothing
  • go to its parent spring-boot-starter-parent-1.3.3.RELEASE.pom, search for Hibernate -> nothing
  • go to its parent spring-boot-dependencies-1.3.3.RELEASE.pom, search for Hibernate -> finally...

可是多么痛苦.当然,您可以检查 http://docs.spring .io/platform/docs/current/reference/htmlsingle/#appendix-dependency-versions ,但这不是Maven应该能够自行找到的信息吗?

But what an ordeal. Of course you could check http://docs.spring.io/platform/docs/current/reference/htmlsingle/#appendix-dependency-versions but isn't that information Maven should be able to find on its own?

推荐答案

我正尝试使用其他答案中的mvn help:effective-pom -Dverbose ,但它对我不起作用,因为它使用的是maven-help-plugin:2.2和

I was trying to use mvn help:effective-pom -Dverbose from this other answer, but it didn't work for me because it was using maven-help-plugin:2.2, and -Dverbose was introduced in 3.2.0.

因此,您应该在命令行中强制版本:

mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:effective-pom -Dverbose=true -Doutput=effective-pom.xml

(最好使用-Doutput,因为文件可能很大,并且在终端中读取它不方便)

(better to use -Doutput because the file can be big and it is not convenient to read it in a terminal)

这篇关于如何查找从BOM表导入的Maven依赖版本声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆