Symfony 6.4下Doctrine XML映射出现“No matching global attribute declaration available”错误的原因排查求助
Symfony 6.4下Doctrine XML映射出现“No matching global attribute declaration available”错误的原因排查求助
大家好,我在Symfony 6.4项目里配置Doctrine XML映射时遇到了一个报错,折腾了好一阵没搞明白问题出在哪,想请各位帮忙看看。
先说说我的环境依赖:
{ "require": { "doctrine/doctrine-bundle": "^2.11.1", "doctrine/doctrine-migrations-bundle": "^3.3.0", "doctrine/orm": "^2.17.2" } }
我的config/packages/doctrine.yaml里的实体管理器配置是这样的:
entity_managers: Default: connection: Default validate_xml_mapping: true
然后是src/Resources/config/doctrine/ByPass.orm.xml的映射文件内容:
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="App\Entity\ByPass" table="bypass" schema="access" repository-class="App\Repository\ByPassRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO" /> </id> <many-to-one field="role" target-entity="App\Entity\Role" inversed-by="bypasses"> <join-column name="role" referenced-column-name="id" on-delete="CASCADE" nullable="false" /> </many-to-one> <field name="created_at" type="datetime" nullable="false" /> <field name="created_by" type="string" length="32" nullable="false" /> <field name="created_ip" type="string" length="256" nullable="false" /> </entity> </doctrine-mapping>
现在运行项目或者验证映射时,会抛出这个错误:
libxml error: Element '{http://doctrine-project.org/schemas/orm/doctrine-mapping}doctrine-mapping', attribute '{https://www.w3.org/2001/XMLSchema-instance}schemaLocation': No matching global attribute declaration available, but demanded by the strict wildcard.
in file:ByPass.orm.xml at line 5
我是照着Doctrine 2.17官方的XML映射文档来写的,但还是遇到了这个问题,有没有人能帮我解释下为什么会出现这个错误?谢谢大家的帮助!
备注:内容来源于stack exchange,提问作者Ludiaz
相关产品推荐
相关产品推荐

