春天。 "schemaLocation ... must have even number of URI's"



来自我的xml文件的摘要:

<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" />

执行后,我会看到以下消息:

警告[wrappersimpleappmain] [xmlbeandefinitionreader]忽略了xml 验证警告org.xml.sax.saxparseexception;亚麻数:14; 柱子:80;示意图:示意图值= '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' 必须有什至数量的URI。 在com.sun.org.apache.xerces.internal.util.erorhandlerwrapper.createsaxparseexception(errorhandlerwrapper.java:198)

如何解决这个问题?

您的 schemaLocation值应为表格

namespace-name schema-location [namespace-name schema-location]

您缺少

http://www.springframework.org/schema/context

之前
http://www.springframework.org/schema/context/spring-context-3.1.xsd

因此应该是

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">

请注意,我将util架构更改为版本3.1。不要混合和匹配。使用所有相同的版本。

示意图必须以命名空间名称架构安装[命名空间名称架构 - 安排]

喜欢示例

xmlns:mytag="http://www.brajesh.com/tagsDef"
xsi:schemaLocation="http://www.brajesh.com/tagsDef
                    http://www.brajesh.com/tagsDef.xsd"

在这里,我们将传达给XML,我们将使用我的自定义标签是" mytag",该标签在http://www.brajesh.com/tagsDef名称空间位置中定义。您可以从http://www.brajesh.com/tagsDef.xsdhttp://www.brajesh.com/tagsDef位置验证这些标签。 由于这个原因,模式位置甚至必须具有URL。

相关内容

最新更新