doushi3819244 2015-06-23 05:32
浏览 55
已采纳

Symfony 2 - 类“Mingle \ StandardBundle \ Entity \ Product”不是有效实体或映射超类

I created a Product.php file in my bundle Mingle\StandardBundle\Entity like this:

<?php

namespace Mingle\StandardBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/*
 * @ORM\Entity
 * @ORM\Table(name="product")
 */

class Product
{
    /*
     * @ORM\Column(type="integer")
     * @ORM\ID
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
    /*
     * @ORM\Column(type="string",length=100)
     */
    protected $name;
    /*
     * @ORM\Column(type="decimal",scale=2)
     */
    protected $price;
    /*
     * @ORM\Column(type="text")
     */
    protected $description;
}
?>

In Ubuntu Terminal, at root folder of Symfony project, I typed this command:

php app/console doctrine:generate:entities Mingle/StandardBundle/Entity/Product

And I encountered problem:

[Doctrine\ORM\Mapping\MappingException]                                      
  Class "Mingle\StandardBundle\Entity\Product" is not a valid entity or mapped super class.

And I don't know how to solve even after searching. Please help

  • 写回答

1条回答 默认 最新

  • duandazhen7306 2015-06-23 05:36
    关注

    Annotations have to be placed inside /** */ comment block, otherwise they are not recognized.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题