[英]Changing the version of a transitive dependency in maven pom.xml
I've been trying to override a transitive dependency version in one of my projects.我一直在尝试在我的一个项目中覆盖传递依赖版本。 I found the following sample project on github to experiment on ( https://github.com/Richou/swagger-codegen-maven-plugin ).
我在 github 上找到了以下示例项目来进行实验( https://github.com/Richou/swagger-codegen-maven-plugin )。 The parent pom of this project contains a dependency for swagger-codegen.
该项目的父 pom 包含对 swagger-codegen 的依赖项。 Swagger-codegen in turn has a dependency called slf4j-ext whose version is 1.6.3.
Swagger-codegen 又具有一个名为 slf4j-ext 的依赖项,其版本为 1.6.3。 I want to upgrade/override the version of slf4j-ext to 1.7.30 from the parent pom.
我想从父 pom 升级/覆盖 slf4j-ext 的版本到 1.7.30。 I tried adding the required slf4j-version inside the property tag in the parent pom but it didn't work when I checked the maven dependency tree.
我尝试在父 pom 的属性标签中添加所需的 slf4j-version,但是当我检查 maven 依赖树时它不起作用。 What is the correct method to do it?
正确的方法是什么?
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen</artifactId>
<version>2.1.2</version>
</dependency>
</dependencies>
<properties>
<slf4j-version>1.7.30</slf4j-version>
<java.version>1.7</java.version>
</properties>
You can add the slf4j-ext with the version you want in the dependencyManagement section of your parent pom.您可以在父 pom 的 dependencyManagement 部分中添加具有所需版本的 slf4j-ext。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>${slf4j-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.