【发布时间】:2014-09-03 19:45:12
【问题描述】:
输入此命令后 (php app/console generate:doctrine:entities CoreBundle:Post
) 通过终端出现以下错误,我该如何解决?
[Doctrine\Common\Annotations\AnnotationException]
[语义错误] 注释 属性中的“@Symfony\Component\Validator\Constraints” Blog\CoreBundle\Entity\Post::$body 不存在,或不能存在 自动加载。
源代码:
namespace Blog\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Post
*
* @ORM\Table()
* @ORM\Entity
*/
class Post extends Timestamp
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="body", type="text")
*
* @Assert|NotBlank
*/
private $body;
/**
* @var Author
*
* @ORM\ManyToOne(targetEntity="Author", inversedBy="posts")
* @ORM\JoinColumn(name="author_id", referecedColumnName="id", nullable=false)
*/
protected $author;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
* @return Post
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set body
*
* @param string $body
* @return Post
*/
public function setBody($body)
{
$this->body = $body;
return $this;
}
/**
* Get body
*
* @return string
*/
public function getBody()
{
return $this->body;
}
}
【问题讨论】:
标签: symfony doctrine-orm