Spring Data Rest - Include nested resource in _embedded

后端 未结 2 2064
陌清茗
陌清茗 2021-01-07 03:55

I\'m developing a Spring Boot Application for a shopping list. For this I use Spring Data Rest to export my entities through a REST API.

My Architecture looks like t

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 05:00

    Define an excerpt projection for Article and configure into its repository with excerptProjection

    Any resource that has defined an excerpt projection will be added to _embedded part fo the response. This applies to collecion resources of associations.

    Read more at https://stackoverflow.com/a/30297320/1203628 or Spring Data REST reference documentation

    An excerpt projection is used whenever an instance of the target type (Article in your case) is used within in an _embedded clause. Thus the excerpt is some kind of preview used everywhere the resource itself is not rendered but pointed to. This is usually the case from collection resources or for associations. Read more on this topic in the Spring Data REST reference documentation.

提交回复
热议问题