英文:
How to check for another dependency version in the maven pom.xml in a Spring Boot project?
问题
在 pom.xml 中的一个依赖需要另一个不存在的依赖:org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon:jar:1.1.2.RELEASE
当我检查这个 1.1.2 版本时,我应该如何在 pom 中操作,以获取 1.1.1 版本?因此,当某个地方检查 1.1.2 版本时,会检查 1.1.1 版本。
提前谢谢!
英文:
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
How can I do in the pom, when this 1.1.2 version is checked, to get the 1.1.1 version? So when something is checking for 1.1.2 version, to check for 1.1.1 version.
Thank you in advance!
答案1
得分: 2
你可以通过依赖管理来强制使用特定版本的传递性依赖。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-ribbon</artifactId>
<version>1.1.1.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
现在只会使用指定的版本,而不使用传递性依赖中声明的版本。
英文:
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.
答案2
得分: 1
除了@Pratapi Hemant Patel提出的建议之外,您还可以在eclipse的pom.xml中转到Dependency Hierarchy选项卡,然后在筛选文本框中搜索spring-cloud-starter-kubernetes-ribbon
,如果不需要的话,可以明确地将其排除掉。
其中一个好处是,您将会知道哪些构件依赖于1.1.2版本。并且还会知道1.1.1是否被1.1.2版本覆盖。基本上,您将会得到所有依赖于1.1.2版本和1.1.1版本的构件。以下是相同内容的图片。
英文:
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.
One benefit of it would be you would know which artifacts has dependency on 1.1.2 version. And also if 1.1.1 is overridden by 1.1.2 version. Basically you will get all artifacts that has dependency on 1.1.2 and also 1.1.1 version. Below is image of same.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论