简体   繁体   English

如何在 Spring Boot 项目的 maven pom.xml 中检查另一个依赖版本?

[英]How to check for another dependency version in the maven pom.xml in a Spring Boot project?

A dependency in the pom.xml needs another dependency that doesn't exist: org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon:jar:1.1.2.RELEASE pom.xml 中的依赖项需要另一个不存在的依赖项:org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon:jar:1.1.2.RELEASE

How can I do in the pom, when this 1.1.2 version is checked, to get the 1.1.1 version?当检查此 1.1.2 版本时,如何在 pom 中获取 1.1.1 版本? So when something is checking for 1.1.2 version, to check for 1.1.1 version.因此,当某些内容正在检查 1.1.2 版本时,请检查 1.1.1 版本。

Thank you in advance!先感谢您!

You can enforce to use specific version of a transitive dependency using dependency management.您可以使用依赖项管理强制使用特定版本的传递依赖项。

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-kubernetes-ribbon</artifactId>
      <version>1.1.1.RELEASE</version>
    </dependency>
  </dependencies>
</dependencyManagement>

Now only the specified version will be used.现在将只使用指定的版本。 Not the versions declared in transitive dependencies.不是在传递依赖项中声明的版本。

Other option than what @Pratapi Hemant Patel has suggested, you can go to Dependency Hierarchy tab in pom.xml in eclipse and search for spring-cloud-starter-kubernetes-ribbon in filter text box and exclude it explicitly if not needed.除了@Pratapi Hemant Patel 建议的其他选项,您可以转到 eclipse 中 pom.xml 中的 Dependency Hierarchy 选项卡,并在过滤器文本框中搜索spring-cloud-starter-kubernetes-ribbon在不需要时明确排除它。

One benefit of it would be you would know which artifacts has dependency on 1.1.2 version.它的一个好处是您会知道哪些工件依赖于 1.1.2 版本。 And also if 1.1.1 is overridden by 1.1.2 version.并且如果 1.1.1 被 1.1.2 版本覆盖。 Basically you will get all artifacts that has dependency on 1.1.2 and also 1.1.1 version.基本上,您将获得所有依赖于 1.1.2 和 1.1.1 版本的工件。 Below is image of same.下面是相同的图像。

发件人图片描述在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM