For example, I want instead of referring to an online XSD like this:
<persistence xmlns="…" xmlns:xsi="…"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://www.oracle.com/…/persistence_2_1.xsd"> <!-- online -->
To refer to a classpath XSD like this:
<persistence xmlns="…" xmlns:xsi="…"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
org/hibernate/jpa/persistence_2_1.xsd"> <!-- classpath -->
There's no standardized way of doing this. Some products may support classpath URIs: classpath:org/hibernate/jpa/persistence_2_1.xsd. If your product doesn't, you can probably write a plugin (LSResourceResolver) that enables the capability.
My team had problem that Spring Boot couldn't find schema for Spring profiled unit tests when xsi:schemaLocation was provided as
classpath:xmlschemas/requiredSchema.xsd
After hours of debugging the solution was to use relative path:
/xmlschemas/requiredSchema.xsd
(xmlschemas directory was in resources root)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With