0

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>
Kenneth Clark
  • 356
  • 1
  • 14
  • Let me guess all your other dependencies (or parent) points to Spring Boot 2.1 or 2.0. – M. Deinum Mar 18 '19 at 09:55
  • That is correct. Spring Boot Parent is 2.1.3.RELEASE, should I include this information in the initial question? – Kenneth Clark Mar 18 '19 at 10:13
  • Never mix jars of different versions of a framework. Either stick with 2.1 or move all to 2.2 but don't mix. That will lead to all sorts of weird issues. – M. Deinum Mar 18 '19 at 10:14
  • Will look into it thanks, I was under the impression major version iterations where the ones to look out for. – Kenneth Clark Mar 18 '19 at 10:15
  • 1
    2.1 and 2.2 are different. 2.1 uses Spring 5.1 , 2.2 uses Spring 5.2 and that is just one of the differences you will pull in. So in the end you will end up mixing even more jars of different frameworks leading to more issues. As stated never mix jars of different versions of frameworks, regardless of the framework. – M. Deinum Mar 18 '19 at 10:16
  • Genius, thanks so much. Would you mind posting this as an answer so I can mark it as such? – Kenneth Clark Mar 18 '19 at 10:53

1 Answers1

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.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
  • Updating the Spring Boot Starter Parent to 2.2.0.M1 resolved my issue, it also allowed me to remove the version in the hateoas dependency declaration. Will keep an eye on https://github.com/spring-projects/spring-boot/releases for future releases. Thanks so much for the help – Kenneth Clark Mar 18 '19 at 11:29
  • 2.2.0 is still "just" a milestone release and not a final one. Consider it BETA. – M. Deinum Mar 18 '19 at 11:36
  • I have taken that into consideration thanks. Can't do much else with the framework unless I get the Affordances API that Hateoas project 1.0.0.M1 has. – Kenneth Clark Mar 18 '19 at 13:04