[英]dispatcher-servlet: Invalid content was found starting with element 'repositories'
我正在尝试使用:
<repositories base-package="com.site.cmt.repositories" repository-impl-postfix="">
<repository id="variableRepository" />
</repositories>
但我不断收到此错误:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自ServletContext资源[/WEB-INF/dispatcher-servlet.xml]的XML文档中的第71行无效; 嵌套的异常是org.xml.sax.SAXParseException; lineNumber:71; columnNumber:94; cvc-complex-type.2.4.a:发现无效的内容(从元素“存储库”开始)。 '{“ http://www.springframework.org/schema/beans":import、"http://www.springframework.org/schema/beans":alias、"http://www.springframework.org”之一/schema/beans”:bean,WC[##other:“http://www.springframework.org/schema/beans”]、“http://www.springframework.org/schema/beans”:beans}'是期待。
我以为我可以正确加载所有内容...
<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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd">
仓库标记的名称空间是错误的,只需将其更改为:
<repository:repositories base-package="com.site.cmt.repositories" repository-impl-postfix="">
<repository:repository id="variableRepository" />
</repository:repositories>
或将xml的默认名称空间设置为存储库:
xmlns="http://www.springframework.org/schema/data/repository"
更新:很抱歉,我弄错了名称空间,在您的情况下,实际上您已经将jpa
用作与存储库相关的正确名称空间的前缀,该名称空间是http://www.springframework.org/schema/data/jpa
,所以您实际上是必须使用:
<jpa:repositories base-package="com.site.cmt.repositories" repository-impl-postfix="">
<jpa:repository id="variableRepository" />
</jpa:repositories>
但最好将存储库前缀重新分配给http://www.springframework.org/schema/data/jpa
命名空间,这是常规做法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.