Symfony2“@Type"在属性 Genius\ProfileBundle\Entity\Profil::$actualites 中从未被导入 [英] Symfony2 "@Type" in property Genius\ProfileBundle\Entity\Profil::$actualites was never imported
本文介绍了Symfony2“@Type"在属性 Genius\ProfileBundle\Entity\Profil::$actualites 中从未被导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
总的来说,我是 Symfony2 的新手.不过,此问题与 JMS 序列化程序注释和 FOSRestBundle 相关.
I am new to Symfony2 in general. This issue relates to JMS Serializer annotations and FOSRestBundle though.
我有以下带有 Actualite 字段的 Profile.php 实体,我希望通过 类型注释.
I have the following Profile.php Entity with an Actualite Field that i'm looking to set them as an Array through Type Annotation.
class Profile {
...
/**
* @ORM\OneToMany(targetEntity="Genius\ProfileBundle\Entity\Actualite", mappedBy="profil",cascade={"persist"}, cascade={"persist", "remove"})
*/
/**
* @Type("array<Actualite>")
*/
private $actualites;
...
}
但我收到以下错误:
"@Type" in property Genius\ProfileBundle\Entity\Profil::$actualites was never imported.
为了解决这个问题,我添加了以下行,但问题仍然存在:
To solve the problem i had add the following line but the problem still :
use Genius\ProfileBundle\Entity\Actualite;
推荐答案
你有没有在你的 Profile 实体中插入这个使用"?
Have you insert this "use" in your Profile entity ?
use JMS\Serializer\Annotation\Type;
你已经设置了你的
@Type("array<Actualie>")
但我认为是
@Type("array<Actualite>")
这篇关于Symfony2“@Type"在属性 Genius\ProfileBundle\Entity\Profil::$actualites 中从未被导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文