kk1957
kk1957

Reputation: 8824

spring load xml definition without external url

In my application which is using Spring framework, at top of my environment.xml I have the usual

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
">

Now I am trying to get rid of the dependency on these external URLs in case they are down. Is there a way to load these XML definitions from some spring or whatever java library. If yes, then how?

Upvotes: 3

Views: 248

Answers (1)

zagyi
zagyi

Reputation: 17518

Spring will load the schema definitions from local resources, as they are included in spring jars. In each jar you find a /META-INF/spring.schemas file that maps the URIs to classpath resources.

Quote from Spring reference docs:

The properties file called 'spring.schemas' contains a mapping of XML Schema locations (referred to along with the schema declaration in XML files that use the schema as part of the 'xsi:schemaLocation' attribute) to classpath resources. This file is needed to prevent Spring from absolutely having to use a default EntityResolver that requires Internet access to retrieve the schema file.

Upvotes: 1

Related Questions