symfony 3 [语义错误]类AppBundle \ Entity \ User中的注释@Doctrine \ ORM \ Mapping \ Model不存在,或者无法自动加载

时间:2017-12-20 07:44:02

标签: php symfony doctrine-orm

当我尝试登录时:

[Semantical Error] The annotation "@Doctrine\ORM\Mapping\Model" in class AppBundle\Entity\User does not exist, or could not be auto-loaded.

我的实体:

    namespace AppBundle\Entity;

    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
    use Symfony\Component\Security\Core\User\UserInterface;
    use Symfony\Component\Validator\Constraints as Assert;
    use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

    /**
     * @ORM\Model()
     * @ORM\Table()
     */
    class User implements UserInterface
    {
    }

我试图将我的代码重新绑定到捆绑包,一切正常。现在出现此错误

enable_annotations为真

我真的不明白应该是什么错 有谁知道吗?

1 个答案:

答案 0 :(得分:0)

我的实体有下一个语法:

use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Symfony\Component\Security\Core\User\UserInterface;

/** @Entity */
class User implements UserInterface
{}

您的实体在哪里?如果您的实体位于Entity文件夹中,则必须更改名称空间,删除User

我的其他实体看起来像这样:

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Usuario
 *
 * @ORM\Table(name="table.usuario", uniqueConstraints= {@ORM\UniqueConstraint(name="matricula_UNIQUE", columns={"matricula"})})
 * @ORM\Entity
 */
 class Usuario
 {}