简体   繁体   English

Symfony 2 - 属性中的注释不存在,或者无法自动加载。

[英]Symfony 2 - The annotation in property does not exist, or could not be auto-loaded.

I'm doing symfony 2 tutorial - Doctrine and databases. 我正在做symfony 2教程 - Doctrine和数据库。

I created the file Pages.php in Entity/Pages.php 我在Entity / Pages.php中创建了Pages.php文件

<?php
namespace Dproc\MainBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @IgnoreAnnotation("fn")
 *
 */
/**
 * @ORM\Entity
 * @ORM\Table(name="pages")
 */
class Pages
{
    /**
     * @ORM\ID
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $ID;

    /**
     * @ORM\Column(type="text")
     */
    protected $page_title;

    /**
     * @ORM\Column(type="text")
     */
    protected $page_content;

    /**
     * @ORM\Column(type="text")
     */
    protected $page_category;
}

Now i'm trying to generate setters and getters for this class using this command. 现在我正在尝试使用此命令为此类生成setter和getter。

php app/console doctrine:generate:entities Dproc/MainBundle/Entity/Pages

It tells : 它说 :

[Doctrine\Common\Annotations\AnnotationException]                            
  [Semantical Error] The annotation "@Doctrine\ORM\Mapping\ID" in property Dp  
  roc\MainBundle\Entity\Pages::$ID does not exist, or could not be auto-loade  
  d. 

What i am doing wrong? 我做错了什么?

Change your $ID with the following code: 使用以下代码更改您的$ ID:

/**
 * @var integer
 *
 * @ORM\Column(type="integer", nullable=false)
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="IDENTITY")
 */
private $id;

我认为这是区分大小写的,请尝试:

@ORM/Id

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 属性中的注释不存在,或者无法自动加载 - The annotation in property does not exist, or could not be auto-loaded 注释不存在,或无法自动加载 - The annotation does not exist, or could not be auto-loaded Symfony2注释“ @Gedmo \\ Mapping \\ Annotation \\ Timestampable”不存在,或者无法自动加载 - Symfony2 The annotation “@Gedmo\Mapping\Annotation\Timestampable” does not exist, or could not be auto-loaded Symfony4 : 注释不存在,或无法自动加载 (Symfony\\Component\\Validator\\Constraints) - Symfony4 : The annotation does not exist, or could not be auto-loaded (Symfony\Component\Validator\Constraints) symfony 3 [语义错误]类AppBundle \\ Entity \\ User中的注释@Doctrine \\ ORM \\ Mapping \\ Model不存在,或者无法自动加载 - symfony 3 [Semantical Error] The annotation @Doctrine\ORM\Mapping\Model in class AppBundle\Entity\User does not exist, or could not be auto-loaded Symfony验证器模块无法自动加载注释 - Symfony validator module the annotation could not be auto loaded Entities \\ USER_User类中的注释“@Doctrine \\ ORM \\ Mapping \\ Entity”不存在,或者无法自动加载 - The annotation “@Doctrine\ORM\Mapping\Entity” in class Entities\USER_User does not exist, or could not be auto-loaded JMSSerializer独立 - 注释不存在,或者无法自动加载 - JMSSerializer stand alone - Annotation does not exist, or cannot be auto-loaded 自定义约束验证器不存在,或无法自动加载 - Custom constraint validator does not exist, or could not be auto-loaded Symfony2-“警告:class_parents():类环境不存在,无法在其中加载” - Symfony2 - “Warning: class_parents(): Class Ambience does not exist and could not be loaded in ”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM