如何将包含 spring-hateoas 版本 1.0.0.M1 的 spring-boot-hateoas-starter 包含到我的项目中 [英] How do I include the spring-boot-hateoas-starter which contains spring-hateoas version 1.0.0.M1 into my project

查看:15
本文介绍了如何将包含 spring-hateoas 版本 1.0.0.M1 的 spring-boot-hateoas-starter 包含到我的项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在尝试使用 Spring 及其相关组件将 .NET 中内置的 API 迁移到 Java.唯一阻止我完成这个项目的是 Spring HATEOAS (0.25.1) 的当前发布版本中缺乏 Affordances,我试图尽可能地复制数据契约,以防止破坏当前使用API.

Spring HATEOAS 包含在 spring-boot-starter-hateoas Maven 依赖项中.

我已经尝试了 starter 依赖的当前构建快照,但无济于事(最新的 spring-hateos 库不包含在 starter 构建快照中).

1) 有没有办法将当前的里程碑版本包含到我的项目中?如果是这样,你建议我怎么做.

2) 如果没有办法做到这一点,有人对如何将 Affordance 概念添加到当前版本有任何建议吗?(在这一点上承担一些技术债务不是问题,所以如果你有一个不雅的工作,请分享它,这将从概念上帮助我).

3) 将 HTTP 返回对象创建为 HashMap 并将其序列化为 JSON 是否更好?(我知道需要手动处理路径等链接)

其他版本:spring-boot-starter-parent: 2.1.3.RELEASE

谢谢

解决方案

关于问题 1) 添加以下依赖项,不要忘记这个依赖项目前来自 Spring Milestone Repository.

>

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

<存储库><id>repository.spring.milestone</id><name>Spring Milestone Repository</name><url>http://repo.spring.io/milestone</url></repository></repositories>

或者,您可以在版本 2.2.0.M1 中使用整个 spring-boot-starter,其中还包含 spring-boot-starter-hateoas1.0.0.M1 中的代码>.

问题 2) 应该不再与您有关,问题 1) 似乎更容易解决.

关于问题 3) 恕我直言,几乎所有地方都应该首选强类型(响应)对象,因为它使您的意图更清晰,更易于维护和测试,并使您免于任何后顾之忧关于强制转换或隐式类型转换等.

Currently I am trying to migrate an API built in .NET to Java using Spring and it's related components. The only thing preventing me from completing this project is the lack of Affordances in the current release version of Spring HATEOAS (0.25.1), I am trying to replicate the data contracts as closely as I can in order to prevent breaking clients currently consuming the API.

Spring HATEOAS is included via the spring-boot-starter-hateoas Maven dependency.

I have tried the current build snapshot of the starter dependency but to no avail (the latest spring-hateos lib is not included in the starter build snapshot).

1) Is there a way to include the current milestone release into my project? If so, how do you recommend I do it.

2) If there is no way to do this, does anyone have any suggestions on how to add the Affordance concept to the current version? (Incurring some tech debt at this point is not a concern, so if you have an inelegant work around please share it, this will help me conceptually).

3) Would it be a better idea to create the HTTP return object as a HashMap and serialize it to JSON? (I understand that link of paths etc would need to be manually handled)

Other Versions: spring-boot-starter-parent: 2.1.3.RELEASE

Thanks

解决方案

Regarding question 1) Add the following dependency and do not forget that this one originates for now from the Spring Milestone Repository.

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

<repositories>
    <repository> 
        <id>repository.spring.milestone</id> 
        <name>Spring Milestone Repository</name> 
        <url>http://repo.spring.io/milestone</url> 
    </repository>
</repositories>

Alternatively you could use the whole spring-boot-starter in version 2.2.0.M1 which also contains spring-boot-starter-hateoas in 1.0.0.M1.

Question 2) should no longer concern you, question 1) seems to be easier solvable.

Regarding question 3) IMHO a strongly-typed (response-) object should almost everywhere be preferred as it makes your intentions more clear, is more easily maintainable and testable and sets you free from any worries about casting or implicit type-conversions and so on.

这篇关于如何将包含 spring-hateoas 版本 1.0.0.M1 的 spring-boot-hateoas-starter 包含到我的项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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