![](/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.