我尝试通过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;
}
}
请检查并告诉我上述代码中是否有任何错误以及如何解决。我尝试了很多其他解决方案,但我仍然无法解决这个问题。
答案 0 :(得分:0)
通过使用以下
替换名称部分来修复它/**
* @var string
*
* @ORM\Column(name="name", type="string", length=150, nullable=false)
*/
private $name;