Spring HATEOAS:如何通过URI发布新的子关联

Spring HATEOAS:如何通过URI发布新的子关联,spring,spring-boot,spring-hateoas,hateoas,Spring,Spring Boot,Spring Hateoas,Hateoas,在Spring Data Rest中,您可以将类似的内容发布到表product\u material中,该表引用product和material: { "product": "http://localhost:8080/api/products/70bdd2a0-3548-4158-b378-71850c4c1eb3", "material": "http://localhost:8080/api/materials/1&qu

在Spring Data Rest中,您可以
将类似的内容发布到表
product\u material
中,该表引用
product
material

{
"product": "http://localhost:8080/api/products/70bdd2a0-3548-4158-b378-71850c4c1eb3",
"material": "http://localhost:8080/api/materials/1"
}

我如何实现这一点,而不是使用
产品
材料
id

您不能使用hateos,因为post请求将尝试使用您提供的链接链接这些子实体”http://localhost:8080/api/materials/1"

另一个选项是放置整个实体,但如果不提供id,它也不会成功,而是创建一个新实体


发出“post”请求后,它将首先搜索ID或版本(如果您提供了),如果没有找到,它将创建一个新的子实体

谢谢,先生。使用id对我来说很好,只是好奇SpringDataREST是如何做到的。你也能回答我的这个问题吗?我非常感谢!