【问题标题】:Error While Creating the schema for doctroin为 doctroin 创建架构时出错
【发布时间】:2017-07-26 18:50:35
【问题描述】:

我尝试通过 CLI 运行 artisan 命令来创建数据库架构,但出现以下错误:

The annotation "@Doctrine\ORM\Mapping\Names" in property App\Entity\Vouchers::$names does not exist, or could not be auto-loaded.

遵循我的实体的代码。

 namespace App\Entity;

 use Doctrine\ORM\Mapping as ORM;

 /**
 * @ORM\Entity
 * @ORM\Table(name="vouchers")
 **/
 class Vouchers
 {
 /**
 * @var integer $id
 * @ORM\Column(name="id", type="integer", unique=true, nullable=false)
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 *
 */
private $id;

/**
 * @var string $names
 * @ORM\Column(name="names", type="string", unique=false, nullable=false)
 * @ORM\Names
 *
 */
private $names;

 /**
 * @var string $amount
 * @ORM\Column(name="amount", type="string", unique=false, nullable=false)
 * @ORM\Amount
 *
 */
 private $amount;


 //Getter And Setters

 //ID
 public function getId()
 {
    return $this->id;
 }

//name

public function getName()
{
    return $this->name;
}

public function setName($name)
{
    $this->name = $name;
}

//amount

public function getAmount()
{
    return $this->amount;
}

public function setAmount($amount)
{
    $this->amount = $amount;
}
}

请检查并让我知道我在上面的代码中是否犯了任何错误以及如何修复它。我已经尝试了许多其他解决方案,但我仍然无法弄清楚这一点。

【问题讨论】:

    标签: laravel-5 orm annotations doctrine syntax-error


    【解决方案1】:

    通过将名称部分替换为以下内容来修复它

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=150, nullable=false)
     */
    private $name;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-26
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-22
      相关资源
      最近更新 更多