Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring RepositoryRestResource注释中的collectionResourceRel等可选元素中“rel”的含义是什么?_Spring_Spring Boot_Spring Data Rest - Fatal编程技术网

Spring RepositoryRestResource注释中的collectionResourceRel等可选元素中“rel”的含义是什么?

Spring RepositoryRestResource注释中的collectionResourceRel等可选元素中“rel”的含义是什么?,spring,spring-boot,spring-data-rest,Spring,Spring Boot,Spring Data Rest,您能帮助我理解RepositoryRestResource注释的collectionResourceRel的可选元素rel的含义吗? 我浏览了Java文档 以下是文档中的内容 collectionResourceRel生成指向的链接时要使用的rel值 收集资源 在HATEOAS API中,rel描述当前上下文源如何与目标资源相关 在HATEOAS API中,rel描述当前上下文源如何与目标资源相关 基本上rel是@RestResource注释的一个属性。它意味着关系 e、 g.订单可能有一个re

您能帮助我理解RepositoryRestResource注释的collectionResourceRel的可选元素rel的含义吗? 我浏览了Java文档

以下是文档中的内容

collectionResourceRel生成指向的链接时要使用的rel值 收集资源

在HATEOAS API中,rel描述当前上下文源如何与目标资源相关

在HATEOAS API中,rel描述当前上下文源如何与目标资源相关

基本上rel是@RestResource注释的一个属性。它意味着关系

e、 g.订单可能有一个rel:customer关系,将订单链接到其客户

发件人:

例如,在默认配置中,如果您向http://localhost:8080/persons/search 要了解公开了哪些查询方法,您将返回一个类似于以下内容的链接列表:

{
  "_links" : {
    "findByName" : {
      "href" : "http://localhost:8080/persons/search/findByName"
    }
  }
}
要更改rel值,请在@RestResource注释上使用rel属性,如下例所示:

@RepositoryRestResource(path = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

  @RestResource(path = "names", rel = "names")
  List<Person> findByName(String name);
}
@RepositoryRestResource(path = "people", rel = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

  @RestResource(path = "names", rel = "names")
  List<Person> findByName(String name);
}
您可以更改存储库的rel,如下例所示:

@RepositoryRestResource(path = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

  @RestResource(path = "names", rel = "names")
  List<Person> findByName(String name);
}
@RepositoryRestResource(path = "people", rel = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

  @RestResource(path = "names", rel = "names")
  List<Person> findByName(String name);
}
rel=people将该链接的名称更改为people


问:您是否有一个示例显示订单可能有一个rel:customer关系,将订单链接到其客户。?它还考虑了诸如OneToMany、MyyOthNi等的实体之间的关系吗? 它不同于实体之间的关系,例如一个多实体、多个多实体

关系描述了当前资源与目标资源的关系

下面是一个很好的例子,可以从中了解rel:

下面给出的JSON响应可能来自HTTP GET之类的API

在前面的示例中,服务器返回的响应包含指向员工资源10/employees的超媒体链接,客户端可以遍历这些链接来读取属于该部门的员工

它位于表示层和数据层之间。借助rel和其他属性创建的链接:

{
    "href": "10/employees",
    "rel": "employees",
    "type" : "GET"
}
帮助应用程序转到正确的方向存储库、方法等,以检索属于该部门的员工的数据

根据您的设计,您还可以在数据层中创建实体之间的关系。但是这些是不同的东西。

基本上rel是@RestResource注释的一个属性。它意味着关系

e、 g.订单可能有一个rel:customer关系,将订单链接到其客户

发件人:

例如,在默认配置中,如果您向http://localhost:8080/persons/search 要了解公开了哪些查询方法,您将返回一个类似于以下内容的链接列表:

{
  "_links" : {
    "findByName" : {
      "href" : "http://localhost:8080/persons/search/findByName"
    }
  }
}
要更改rel值,请在@RestResource注释上使用rel属性,如下例所示:

@RepositoryRestResource(path = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

  @RestResource(path = "names", rel = "names")
  List<Person> findByName(String name);
}
@RepositoryRestResource(path = "people", rel = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

  @RestResource(path = "names", rel = "names")
  List<Person> findByName(String name);
}
您可以更改存储库的rel,如下例所示:

@RepositoryRestResource(path = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

  @RestResource(path = "names", rel = "names")
  List<Person> findByName(String name);
}
@RepositoryRestResource(path = "people", rel = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

  @RestResource(path = "names", rel = "names")
  List<Person> findByName(String name);
}
rel=people将该链接的名称更改为people


问:您是否有一个示例显示订单可能有一个rel:customer关系,将订单链接到其客户。?它还考虑了诸如OneToMany、MyyOthNi等的实体之间的关系吗? 它不同于实体之间的关系,例如一个多实体、多个多实体

关系描述了当前资源与目标资源的关系

下面是一个很好的例子,可以从中了解rel:

下面给出的JSON响应可能来自HTTP GET之类的API

在前面的示例中,服务器返回的响应包含指向员工资源10/employees的超媒体链接,客户端可以遍历这些链接来读取属于该部门的员工

它位于表示层和数据层之间。借助rel和其他属性创建的链接:

{
    "href": "10/employees",
    "rel": "employees",
    "type" : "GET"
}
帮助应用程序转到正确的方向存储库、方法等,以检索属于该部门的员工的数据


根据您的设计,您还可以在数据层中创建实体之间的关系。但是这些是不同的。

您是否有一个示例显示订单可能有一个rel:customer关系,将订单链接到其客户。?它是否还考虑了诸如OneToMany、ManyToMany etc.这样的实体之间的关系,如果情况是这样的呢?你有一个例子,显示一个订单可能有一个将客户订单与客户联系起来的客户关系。它是否也考虑了实体,如OneToMany,ManyToMany etc.之间的关系,如果是这样的话,它会如何表现?