Validation 从错误的命名空间加载约束验证器命名空间

Validation 从错误的命名空间加载约束验证器命名空间,validation,symfony,Validation,Symfony,我试图在symfony2中创建自定义验证器,但它从错误的名称空间加载。错误是: 试图从命名空间“Symfony\Component\Validator\Constraints\errad\MainBundle\Validator\Constraints”加载类“DateChecker” 这是我的密码: MainBundle/Validator/Constraints/DateCheker.php: <?php namespace Errand\MainBundle\Validator\C

我试图在symfony2中创建自定义验证器,但它从错误的名称空间加载。错误是:

试图从命名空间“Symfony\Component\Validator\Constraints\errad\MainBundle\Validator\Constraints”加载类“DateChecker”

这是我的密码:

MainBundle/Validator/Constraints/DateCheker.php:

<?php

namespace Errand\MainBundle\Validator\Constraints;

use Symfony\Component\Validator\Constraint;

/**
 * @Annotation
 */
class DateChecker extends Constraint
{
    /**
     *
     * @var string
     */
    public $message = 'some message';

    /**
     *
     * @return string
     */
    public function validatedBy()
    {
        return get_class($this).'Validator';
    }

    /**
     * Get class constraints and properties
     *
     * @return array
     */
    public function getTargets()
    {
        return array(self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT);
    }
}
MainBundle/Resources/config/validation.yml:

Errand\MainBundle\Entity\Task:
    constraints:
        - Errand\MainBundle\Validator\Constraints\DateChecker: ~

你试过清除缓存了吗?是的,没用。
Errand\MainBundle\Entity\Task:
    constraints:
        - Errand\MainBundle\Validator\Constraints\DateChecker: ~