输入此命令后php app/console generate:doctrine:entities CoreBundle:Post
)终端出现以下错误,我该如何解决?
[学说\共同\注解\ 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;
}
}
答案 0 :(得分:3)
我认为@Assert
属性的$body
注释中有拼写错误。您使用竖线符号|
而不是反斜杠\
。