Maven版本在哪里被覆盖? [英] where does the maven version get overridden?

查看:892
本文介绍了Maven版本在哪里被覆盖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照建议的约定(核心/自动配置/启动器模块分离)构建一个弹簧启动启动器.当我查看Maven依赖树时,这就是我所拥有的:

I am building a spring boot starter, following the recommended convention with core / autoconfigure / starter module separation. When I look at the maven dependency-tree, this is what I have :

[INFO] com.myDomain.myProject:myProject-starter:jar:1.0.8-SNAPSHOT
[INFO] +- com.myDomain.myProject:myProject-autoconfigure:jar:1.0.8-SNAPSHOT:compile
[INFO] |  \- com.myDomain.myProject:myProject-core:jar:1.0.8-SNAPSHOT:compile
[INFO] |     +- io.github.openfeign:feign-gson:jar:9.5.1:compile
[INFO] |     |  +- io.github.openfeign:feign-core:jar:9.5.1:compile
[INFO] |     |  \- com.google.code.gson:gson:jar:2.8.5:compile

gson出现在v2.8.5中,这是我期望的版本-我的项目可以使用它

(注意:在 https://mvnrepository.com中/artifact/io.github.openfeign/feign-core/9.5.1 ,我们看到gson的预期版本是2.5 ...所以不确定为什么我会得到2.8.5 ..)

(note : in https://mvnrepository.com/artifact/io.github.openfeign/feign-core/9.5.1 , we see that the expected version for gson is 2.5... so not sure why I get 2.8.5..)

在我的根pom.xml中,这样声明BOM:

In my root pom.xml, I declare the BOM like this :

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-openfeign-dependencies</artifactId>
            <version>2.0.1.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

并在我的核心" pom.xml中:

and in my "core" pom.xml :

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>

    <dependency>
        <groupId>io.github.openfeign</groupId>
        <artifactId>feign-gson</artifactId>
    </dependency>

    <dependency>
        <groupId>io.github.openfeign</groupId>
        <artifactId>feign-httpclient</artifactId>
    </dependency>
</dependencies>

现在,在另一个项目中,我使用启动器.所以我的pom.xml很简单:

Now, in another project, I use the starter. So my pom.xml is very simple :

<dependencies>
    <dependency>
        <groupId>com.myDomain.myProject</groupId>
        <artifactId>myProject-starter</artifactId>
        <version>1.0.8-SNAPSHOT</version>
    </dependency>
</dependencies>

当我在这个项目中查看依赖关系树时,我得到了:

When I look at the dependency tree in this project, I get this :

[INFO] \- com.myDomain.myProject:myProject-starter:jar:1.0.8-SNAPSHOT:compile
[INFO]    +- com.myDomain.myProject:myProject-autoconfigure:jar:1.0.8-SNAPSHOT:compile
[INFO]    |  \- com.myDomain.myProject:myProject-core:jar:1.0.8-SNAPSHOT:compile
[INFO]    |     +- io.github.openfeign:feign-gson:jar:9.5.1:compile
[INFO]    |     |  +- io.github.openfeign:feign-core:jar:9.5.1:compile
[INFO]    |     |  \- com.google.code.gson:gson:jar:2.5:compile

gson出现在v2.5中,因此它不起作用.如果我在pom.xml中覆盖它,可以在启动程序之前声明gson 2.8.5,然后它就可以工作了..

gson comes in v2.5, and because of that it doesn't work. If I override it in the pom.xml, by declaring gson 2.8.5 before the starter, then it works..

但是Maven的工作方式一定缺少我的东西.

But there must be something that I am missing in the way Maven works..

我尝试从本地存储库中删除1.0.8快照版本,然后对其进行重建,以确保我的第二个项目没有采用较旧的版本,但是我一直在构建中获取此不正确的版本,并且我不知道它来自哪里/什么覆盖了它.

I've tried deleting the 1.0.8-snapshot version from my local repo, then rebuild, it, to make sure my second project was not taking an older version, but I keep getting this incorrect version in my build, and I have no clue where it's coming from / what overrides it.

代码: https://github.com/societe-generale/github-crawler/tree/sprinBoot2upgrade

我真的很感兴趣任何调查指针,以了解根本原因,因为我现在很困惑.

I am really interested in any pointer for investigation, to understand the root cause, because I am quite confused right now..

谢谢!

=======================================

=========================================

编辑1

如评论中所述,是Spring Boot启动程序将gson版本覆盖为2.8.5(而不是feign-core中计划的2.5).

As mentioned in comments, it's Spring Boot starter that overrides the gson version to 2.8.5 (instead of the 2.5 planned in feign-core).

因此,现在的问题变成了:当我将启动器用作没有父项的另一个项目中的单个依赖项时,覆盖的版本(2.8.5)消失了,而我得到的初始版本(2.5)又是为什么呢?与spring-boot-autoconfigure 2.0.4.RELEASE不兼容?

So now the question becomes : how come that when I use the starter as the single dependency in another project with no parent, that overridden version (2.8.5) disappears and I end up with the initial version (2.5) that is not compatible with spring-boot-autoconfigure 2.0.4.RELEASE ?

编辑2

我在这里创建了一个新的,更集中的问题:

I have created a fresh, more focused question here : Not getting the expected version when using the Spring Boot starter I built

推荐答案

基于问题注释中各种提示的快速摘要

quick summary based on the various hints in the question comments

详细模式是自Maven 3.x以来已停产,因此请使用mvndependency:tree -X获取有关已使用/已覆盖版本的更多详细信息,然后您将得到类似的信息:

Verbose mode is discontinued since Maven 3.x, so use mvn dependency:tree -X to get more details on versions used/overridden, etc. Then you get something like that :

[DEBUG] io.github.openfeign:feign-gson:jar:9.5.1:compile 
[DEBUG]    com.google.code.gson:gson:jar:2.8.5:compile (version managed from 2.5 by org.springframework.boot:spring-boot-dependencies:2.0.4.RELEASE)

->这清楚地指出了版本的来源,即

-> this points quite clearly to where the version is coming from, ie https://github.com/spring-projects/spring-boot/blob/v2.0.4.RELEASE/spring-boot-project/spring-boot-dependencies/pom.xml#L65

这篇关于Maven版本在哪里被覆盖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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