错误:在 Spring 调度程序中的命名空间上"schemaLocation value *** must have even number of URI's."



出现以下错误

<Ignored XML validation warning> org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 55;
SchemaLocation: schemaLocation value = 'http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx' must have even number of URI's.

和我的分派器servlet有以下命名空间

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">  

,我用以下

替换了上面的所有内容
<beans xmlns="http://www.springframework.org/schema/beans"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">  

我的错误消失了。
有人知道是怎么发生的吗?

schemaLocation属性引用命名空间的XML Schema文档。

基本上当你输入:

xmlns:expns="http://www.example.com"
xsi:schemaLocation="http://www.example.com
                    http://www.example.com/schema/example.xsd"

你说的是:"我要使用前缀 expns 命名空间 http://www.example.com 的元素。另外,为了验证这些元素,可以在 http://www.example.com/schema/example.xsd "

中获取 http://www.example.com 的XSD模式文件。

也就是说,格式是:

xsi:schemaLocation="namespace-a   where_to_get_the_xsd_for_namespace-a
                    namespace-b   where_to_get_the_xsd_for_namespace-b
                    namespace-c   where_to_get_the_xsd_for_namespace-c"

等等

这就是为什么它必须是偶数的原因。


更多信息和示例可以在这里找到。

@acdcjunior解释是正确的,要解决OP的问题,需要添加缺少的命名空间p的schemaLocation

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/p http://www.springframework.org/schema/xx-xx.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

另外,如果名称空间定义和schemaLocation定义的顺序不同,也会出现此警告

相关内容

最新更新