簡體   English   中英

Symfony2 Jobeet教程第3天錯誤無效映射

[英]Symfony2 Jobeet tutorial day 3 error invalid mapping

當我使用代碼生成包實體時

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 ]

嘗試在文本編輯器中打開文件,並在全局范圍內將“”替換為“”。

我的同事在同一個文件上遇到完全相同的問題,事實證明問題是該文件使用了除空格之外的其他東西作為空格。 file(1)顯示該文件是UTF-8 Unicode文本而不是純ASCII文本。

我相信這可能是由使用不同空格字符的復制+粘貼的來源引起的。

此yaml .yml配置文件不能包含TAB。 只有空間作為意圖。 那就是問題所在。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM