首页 > 架构设计 > > 什么是 Spring Date REST
Spring Date TEST 可以用来发布关于 Spring 数据库的 HATEOAS RESTful 资源。
下面是一个使用 JPA 的例子
@RepositoryRestResource(collectionResourceRel = "todos", path = "todos")
public interface TodoRepository
extends PagingAndSortingRepository<Todo, Long> {不需要写太多代码,我们可以发布关于 Spring 数据库的 RESTful API。
下面展示的是一些关于 TEST 服务器的例子
URL:http://localhost:8080/todos
Use Header:Content-Type:Type:application/json
Request Content
代码如下
{
"user": "Jill",
"desc": "Learn Hibernate",
"done": false
}{
"user": "Jill",
"desc": "Learn Hibernate",
"done": false,
"_links": {
"self": {
"href": "http://localhost:8080/todos/1"
},
"todo": {
"href": "http://localhost:8080/todos/1"
}
}
}响应包含新创建资源的 href。 欢迎大家加我qq:1038774626探讨技术问题。
欢迎大家加我qq:1038774626探讨技术问题。
欢迎大家加我qq:1038774626探讨技术问题。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69952307/viewspace-3145836/ ,如需转载,请注明出处,否则将追究法律责任。