【问题标题】:Symfony2 Jobeet tutorial day 3 error invalid mappingSymfony2 Jobeet 教程第 3 天报错无效映射
【发布时间】:2013-05-18 12:36:20
【问题描述】:

当我使用代码生成捆绑实体时

php app/console doctrine:generate:entities EnsJobeetBundle

我收到了这个错误

[Doctrine\Common\Persistence\Mapping\MappingException] 类“Ens\JobeetBundle\Entity\Affiliate”的映射文件“Ens.JobeetBundle.Entity.Affiliate.orm.yml”无效。

这是 Affiliate.orm.yml 文件:

 Ens\JobeetBundle\Entity\Affiliate:
  type: entity
  table: affiliate
  id:
    id:
      type: integer
      generator: { strategy: AUTO }
  fields:
    url:
      type: string
      length: 255
    email:
      type: string
      length: 255
      unique: true
    token:
      type: string
      length: 255
    created_at:
      type: datetime
  oneToMany:
    category_affiliates:
      targetEntity: CategoryAffiliate
      mappedBy: affiliate
  lifecycleCallbacks:
    prePersist: [ setCreatedAtValue ]

【问题讨论】:

标签: php symfony mapping symfony-2.1 jobeet


【解决方案1】:

尝试在文本编辑器中打开文件,并在全局范围内将“”替换为“”。

我的同事在同一个文件上遇到了完全相同的问题,结果发现问题是该文件使用了除空格以外的其他内容作为空格。 file(1) 表明该文件是 UTF-8 Unicode 文本而不是纯 ASCII。

我认为这可能是由于复制+粘贴的来源使用了不同的空格字符造成的。

【讨论】:

  • 还是有同样的问题。
【解决方案2】:

此 yaml .yml 配置文件不能包含 TAB。只有空格作为意图。这就是问题所在。

【讨论】:

    猜你喜欢
    • 2014-01-29
    • 1970-01-01
    • 2015-01-09
    • 1970-01-01
    • 1970-01-01
    • 2018-11-13
    • 2013-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多