cvc-elt.1:找不到元素'beans'的声明 - applicationcontext.xml

时间:2015-09-22 15:59:01

标签: spring applicationcontext

我最终只收到此错误: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自类路径资源[applicationContext.xml]的XML文档中的第12行无效;嵌套异常是org.xml.sax.SAXParseException; cvc-elt.1:找不到元素'beans'的声明。 我看到已经存在bean的声明

有人可以帮我解决我出错的地方吗?

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" 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-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">

<mvc:annotation-driven>
</mvc:annotation-driven>

                                                                     

Spring jar存在是4.1.6。

2 个答案:

答案 0 :(得分:2)

这是您更正的文件:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" 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-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">

<mvc:annotation-driven>
</mvc:annotation-driven>
</beans>

你写了xsi:schemalocation而不是xsi:schemaLocation(注意大写 L

答案 1 :(得分:0)

有关xsi:schemaLocation的更多信息:

XML解析器将从Internet读取架构位置并使用它来验证xml。如果你没有互联网接入(大多数生产系统没有外出互联网接入),春天来救援。它解释读取请求并从Spring jar中加载模式。