gpt4 book ai didi

java - 调度程序 servlet : Invalid content was found starting with element 'repositories'

转载 作者:行者123 更新时间:2023-12-04 20:44:51 25 4
gpt4 key购买 nike

我正在尝试使用:

<repositories base-package="com.site.cmt.repositories" repository-impl-postfix="">
<repository id="variableRepository" />
</repositories>

但我一直收到这个错误:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 71 in XML document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 71; columnNumber: 94; cvc-complex-type.2.4.a: Invalid content was found starting with element 'repositories'. One of '{"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}' is expected.

我以为我正在正确加载所有内容......

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

最佳答案

repositories 标签的命名空间有误,改成:

<repository:repositories base-package="com.site.cmt.repositories" repository-impl-postfix="">
<repository:repository id="variableRepository" />
</repository:repositories>

或者设置xml的默认命名空间为repository:

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 命名空间可能会更好,这是正常的 convention

关于java - 调度程序 servlet : Invalid content was found starting with element 'repositories' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10600861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com