![](/img/trans.png)
[英]A circular reference has been detected when serializing the object of class "App\Entity\Catalog" (configured limit: 1)
[英]"hydra:description": "A circular reference has been detected when serializing the object of class \"App\\Entity\\Category\" (configured limit: 1).",
我正在使用 Api 平台和 Symfony 5.4,類別上的 ManyTomany 關系,我有這個錯誤
我找到了解決方案:通過在 Category 實體上添加 @ApiResource 。
是因為Category沒有標注@ApiResource,所以沒有被API平台處理(是Symfony平台),因為存在循環引用,所以會報錯。 如果類別中有 API 資源,循環引用將自動處理。 如果你不想讓它成為一個資源,你需要自己注冊一個循環引用處理器: https://symfony.com/doc/current/components/serializer.html#handling-circular-references
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.