Spring Data Rest 没有 HATEOAS [英] Spring Data Rest Without HATEOAS

查看:34
本文介绍了Spring Data Rest 没有 HATEOAS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢 Spring Data Rest 为您编写的所有样板代码,但我宁愿只有一个常规?"没有所有 HATEOAS 东西的 REST 服务器.主要原因是我在客户端使用 Dojo Toolkit,它的所有小部件和商店都设置为返回的 json 只是一个直接的项目数组,没有所有链接和类似的东西.有谁知道如何使用 java config 配置它,以便我获得为我编写的所有 mvc 代码,但没有所有 HATEOAS 的东西?

I really like all the boilerplate code Spring Data Rest writes for you, but I'd rather have just a 'regular?' REST server without all the HATEOAS stuff. The main reason is that I use Dojo Toolkit on the client side, and all of its widgets and stores are set up such that the json returned is just a straight array of items, without all the links and things like that. Does anyone know how to configure this with java config so that I get all the mvc code written for me, but without all the HATEOAS stuff?

推荐答案

在阅读 Oliver 的评论(我同意)后,您仍然想从 Spring Boot 中删除 HATEOAS.

After reading Oliver's comment (which I agree with) and you still want to remove HATEOAS from spring boot.

在包含您的主要方法的类的声明上方添加:

Add this above the declaration of the class containing your main method:

@SpringBootApplication(exclude = RepositoryRestMvcAutoConfiguration.class)

正如 Zack 在评论中所指出的,您还需要创建一个控制器来公开所需的 REST 方法(findAll、save、findById 等).

As pointed out by Zack in the comments, you also need to create a controller which exposes the required REST methods (findAll, save, findById, etc).

这篇关于Spring Data Rest 没有 HATEOAS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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