Reputation: 37016
snippet from my xml file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<!-- http://www.springframework.org/schema/aop -->
<!-- http://www.springframework.org/schema/aop/spring-aop.xsd"> -->
<context:component-scan base-package="myPackage" />
after execution I see following message:
WARN [WrapperSimpleAppMain] [XmlBeanDefinitionReader] Ignored XML validation warning org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 80; SchemaLocation: schemaLocation value = 'http://www.springfr amework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.spri ngframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springfra mework.org/schema/context/spring-context-3.1.xsd' must have even number of URI's. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
How to solve this problem right?
Upvotes: 3
Views: 12961
Reputation: 280174
Your schemaLocation
value should be of the form
namespace-name schema-location [namespace-name schema-location]
You're missing
http://www.springframework.org/schema/context
before
http://www.springframework.org/schema/context/spring-context-3.1.xsd
It should therefore be
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
Note that I've changed the util
schema to version 3.1. Don't mix and match. Use all the same versions.
Upvotes: 15
Reputation: 1555
SchemaLocation must be in the form of namespace-name schema-location [namespace-name schema-location]
like example
xmlns:mytag="http://www.brajesh.com/tagsDef"
xsi:schemaLocation="http://www.brajesh.com/tagsDef
http://www.brajesh.com/tagsDef.xsd"
Here we are conveying to xml that, we are going to use my custom tag that is 'mytag' which is defined in http://www.brajesh.com/tagsDef
name-space location.
You can validate these tags from http://www.brajesh.com/tagsDef.xsd
location for http://www.brajesh.com/tagsDef
.
Due to this reason, schema location must have even URLs.
Upvotes: 1