自定义字段上的Symfony注释错误

时间:2017-01-14 04:23:45

标签: annotations doctrine symfony

我是Symfony 3的新手,我无法在网上找到有利的解决方案。所以我提出这个问题。

我的实体类如下:

// src/AppBundle/Entity/TimeTable.php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;


/**
 * @ORM\Entity
 * @ORM\Table(name="time_table")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\TimeTableRepository")
 * @UniqueEntity(fields={"dateid","trend"}, message="Duplicate Entry")
 */

class TimeTable
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;


    /**
     * @ORM\dateid
     * @ORM\Column(type="integer")
     * @Assert\NotBlank()
     */
    private $dateid;

    /**
     * @ORM\trend
     * @ORM\Column(type="integer")
     * @Assert\NotBlank()
     */
    private $trend;

    /**
     * @ORM\mmpy
     * @ORM\Column(type="decimal")
     * @Assert\NotBlank()
     */
    private $mmpy;

    public function getDateid()
    {
        return $this->dateid;
    }

    public function setDateid($dateid)
    {
        $this->date = $dateid;
    }

    public function getTrend()
    {
        return $this->trend;
    }

    public function setTrend($trend)
    {
        $this->trend = $trend;
    }

    public function getMmpy()
    {
        return $this->mmpy;
    }

    public function setMmpy($mmpy)
    {
        $this->mmpy = $mmpy;
    }
}

当我运行以下命令时:php bin/console doctrine:schema:validate

它引发了我的错误:

[Semantical Error] The annotation "@Doctrine\ORM\Mapping\dateid" in property AppBundle\Entity\TimeTable::$dateid do
  es not exist, or could not be auto-loaded.

知道导致问题的原因是什么以及如何克服它?

仅供参考:我正在使用Symfony 3.2

,非常感谢

1 个答案:

答案 0 :(得分:0)

因为它不是valid Doctrine annotation

你也有,

loggerFactory.AddNLog();
var configuration = LogManager.Configuration;

var target = new FileTarget {
    Name = "log",
    FileName = "logs/logging.log",
    Layout = "${longdate}|${eventproperties:item=EventId.Id}|${logger}|${uppercase:${level}}|  ${message} ${exception}",
    ArchiveEvery = FileArchivePeriod.Day
}

var wrappedTarget = new AsyncTargetWrapper {
    Name = "wrappedTarget",
    WrappedTarget = target
};

configuration.AddTarget(wrappedTarget);

它们看起来也没有效果。你从哪里得到的。也许是一篇旧文章?