cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'util:properties'的声明

时间:2013-04-23 15:54:53

标签: spring xsd

我的spring配置文件就像这样

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        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">
.
.
.
<util:properties id="mailProperties">
        <prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
        <prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable}</prop>
        <prop key="mail.smtp.quitwait">${mail.smtp.quitwait}</prop>
        <prop key="mail.smtp.debug">${mail.smtp.debug}</prop>
    </util:properties>

我在config xml文件中遇到错误

schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/util/spring-util-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

让我知道需要做什么

1 个答案:

答案 0 :(得分:0)

尝试摆脱所有.xsd前面的-3.0。 我遇到了这个愚蠢的错误,删除版本已经工作的版本号对我有用。

我无法告诉你为什么会这样。如果您查看org.springframework.beans-3.1.2.jar(例如)并找到META-INF / spring.schemas,您将找到所有这些


http\://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd
http\://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd
http\://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
http\://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd
http\://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd

你会在那里找到架构,那么为什么XML解析器抱怨对我来说是一个谜。