duanhun3273 2017-12-20 07:44
浏览 103

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

when i am trying to log in:

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

My entity:

    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
    {
    }

I have tried to refarcor my code to bundles and everything was working. Now this error shows up

enable_annotations is true

I really do not understand what should be wrong Does anyone know?

  • 写回答

1条回答 默认 最新

  • duanlv1366 2017-12-20 08:40
    关注

    My entity has the next syntax:

    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
    {}
    

    Where is your entity? if you entity is in the folder Entity you must change your namespace removing User.

    Other of my Entities looks like this:

    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
     {}
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?