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 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算