Maven不正确的依赖版本解析 [英] Maven incorrect dependancy version resolution

查看:415
本文介绍了Maven不正确的依赖版本解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当包含最新的Spring Hateoas Starter时,Maven下载了错误的Spring Hateoas.

When including the latest Spring Hateoas Starter, Maven is downloading the incorrect Spring Hateoas.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-hateoas</artifactId>
    <version>2.2.0.M1</version>
</dependency>

运行maven依赖关系树时,我得到以下信息:

When I run the maven dependency tree I get the following:

> mvn dependency:tree | grep hateoas
INFO] +- org.springframework.boot:spring-boot-starter-hateoas:jar:2.2.0.M1:compile
[INFO] |  +- org.springframework.hateoas:spring-hateoas:jar:0.25.1.RELEASE:compile

这似乎不正确,因为POM列出了1.0.0.M1作为要包括的版本:

This doesn't seem correct as the POM lists 1.0.0.M1 as the version to include: Spring Hateoas Starter POM

我试图清除高速缓存,并手动删除了高速缓存,然后运行mvn -U.结果始终是相同的.

I have attempted to purge the cache and have manually removed the cache and then run mvn -U. The outcome is always the same.

其他信息:

Apache Maven 3.5.4 (Red Hat 3.5.4-4)
Maven home: /usr/share/maven
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-2.fc29.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.20.14-200.fc29.x86_64", arch: "amd64", family: "unix"
<repositories>
    <repository> 
        <id>repository.spring.milestone</id> 
        <name>Spring Milestone Repository</name> 
        <url>http://repo.spring.io/milestone</url> 
    </repository>
</repositories>

推荐答案

根据经验," 请勿混合来自不同版本框架的jars ".在这种情况下,您尝试将Spring Boot 2.1与更新的Spring Boot 2.2 jar混合使用.这将导致各种奇怪的问题,因为它们还会引入不同的框架版本. (春季5.2等)

As a rule of thumb "never mix jars from different versions of a framework". In this case you are trying to mix Spring Boot 2.1 with newer Spring Boot 2.2 jars. This will lead to all sorts of weird issues as they also pull in different framework versions. (Spring 5.2 etc.)

现在,通过使用spring-boot-starter-parent作为项目的父级,可以部分避免这种情况,因为它可以有效地管理依赖性版本.另请参见参考指南的本部分.

Now this is partially prevented by using the spring-boot-starter-parent as the parent for your project as that, quite, forcefully manages the dependency versions. See also this section of the reference guide.

如果您想在当前的Spring Boot版本中尝试另一个Spring HATEOAS版本,则可以尝试覆盖spring-hateoas.version属性.您仍将需要里程碑或快照存储库.

If you want to try another Spring HATEOAS version with your current Spring Boot version you can try to override the spring-hateoas.version property. You would still need the milestone or snapshot repo for that.

但是我不确定Spring HATEOAS 1.x是否使用Spring 5.1或其他版本.

I'm not sure however if Spring HATEOAS 1.x uses Spring 5.1 or another version.

这篇关于Maven不正确的依赖版本解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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