Xml 如何在xsi:schemaLocation中引用类路径XSD?
例如,我希望不要像这样引用在线XSD:Xml 如何在xsi:schemaLocation中引用类路径XSD?,xml,Xml,例如,我希望不要像这样引用在线XSD: <persistence xmlns="…" xmlns:xsi="…" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://www.oracle.com/…/persistence_2_1.xsd"> <!-- online --> <persistence xmlns="…" xmlns:xsi="…" xsi:s
<persistence xmlns="…" xmlns:xsi="…"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://www.oracle.com/…/persistence_2_1.xsd"> <!-- online -->
<persistence xmlns="…" xmlns:xsi="…"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
org/hibernate/jpa/persistence_2_1.xsd"> <!-- classpath -->
要像这样引用类路径XSD:
<persistence xmlns="…" xmlns:xsi="…"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://www.oracle.com/…/persistence_2_1.xsd"> <!-- online -->
<persistence xmlns="…" xmlns:xsi="…"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
org/hibernate/jpa/persistence_2_1.xsd"> <!-- classpath -->
没有标准化的方法。一些产品可能支持类路径URI:classpath:org/hibernate/jpa/persistence_2_1.xsd
。如果您的产品没有,您可能可以编写一个插件(lsresourcesolver)来启用该功能。我的团队遇到了一个问题,即当xsi:schemaLocation
作为
classpath:xmlschemas/requiredSchema.xsd
调试数小时后,解决方案是使用相对路径:
/xmlschemas/requiredSchema.xsd
(xmlschemas目录位于资源根目录中)使用XML目录。另见