无法递归地在bean标记上找到元素'beans'的声明

时间:2014-02-04 02:39:50

标签: spring

我收到以下错误:

引起:org.xml.sax.SAXParseException:cvc-elt.1:找不到元素'beans'的声明。

我的context.xml如下

<?xml version="1.0" encoding="UTF-8"?>

<beans default-autowire="no"
    xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
    http://www.springframework.org/schema/beans/spring-beans.xsd">

      <bean id="fileParser" class="com.xxx.xx.xx.oxm.FileInputParser" >
        <property name="unmarshaller" ref ="jaxb2Marshaller" />
    </bean>

    <bean id = "jaxb2Marshaller" class = "org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name = "classesToBeBound">
            <array>
                <value>com.xxx.xx.xx.oxm.XutoxenPathInfo</value>
            </array>
        </property>
    </bean>

</beans>

1 个答案:

答案 0 :(得分:0)

您的schemaLocation编写错误。该位置需要遵循命名空间名称。

xsi:schemaLocation="http://www.springframework.org/schema/beans 
                    http://www.springframework.org/schema/beans/spring-beans.xsd 
                    http://www.springframework.org/schema/context 
                    http://www.springframework.org/schema/context/spring-context-3.1.xsd">

你的不这样做。这是

beansNS 
contextNS 
contextLocation
beansLocation