dongyang0005
2013-05-18 12:36
浏览 64
已采纳

Symfony2 Jobeet教程第3天错误无效映射

When I generate bundle entities with code

php app/console doctrine:generate:entities EnsJobeetBundle

I'm getting this error

[Doctrine\Common\Persistence\Mapping\MappingException] Invalid mapping file 'Ens.JobeetBundle.Entity.Affiliate.orm.yml' for class 'Ens\JobeetBundle\Entity\Affiliate'.

This is Affiliate.orm.yml file:

 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 ]

图片转代码服务由CSDN问答提供 功能建议

当我使用代码生成包实体时

  php app /  console doctrine:generate:entities EnsJobeetBundle 
   
 
 

我收到此错误

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

这是Affiliate.orm.yml文件:

  Ens \ JobeetBundle \ Entity \ Affiliate:
 type:entity 
 table:affiliate 
 id:\  n id:
 type:integer 
 generator:{strategy:AUTO} 
 fields:
 url:
 type:string 
 length:255 
 email:
 type:string 
 length:255 \  n unique:true 
 token:
 type:string 
 length:255 
 created_at:
 type:datetime 
 oneToMany:
 category_affiliates:
 targetEntity:CategoryAffiliate 
 mappedBy:affiliate 
 lifecycleCallbacks:\  n prePersist:[  setCreatedAtValue] 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • drxyaox153896 2013-05-31 14:08
    已采纳

    Try opening the file in a text editor, and replacing " " with " " globally.

    My colleague was having the exact same issue on the same file, and it turns out the problem was that the file was using something other than spaces as spaces. file(1) showed that the file was a UTF-8 Unicode text rather than plain ASCII.

    I believe this may be caused by the source of the copy + paste using different space characters.

    已采纳该答案
    打赏 评论
  • dpn4073 2014-02-28 12:25

    This yaml .yml configuration files cannot contain TABs. Only spaces as intendation. That is the problem.

    打赏 评论

相关推荐 更多相似问题