Maven incorrect dependancy version resolution

梦想的初衷 提交于 2019-12-25 03:22:55

问题


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>

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

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

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

Additional information:

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>

回答1:


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.)

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.

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.

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



来源:https://stackoverflow.com/questions/55217926/maven-incorrect-dependancy-version-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!