【问题标题】:Invalid content was found starting with element 'jpa:repository'发现以元素“jpa:repository”开头的无效内容
【发布时间】:2013-01-02 04:48:12
【问题描述】:

我在 spring-data-jpa 中使用这个:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" 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.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.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-3.2.xsd
    http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
default-lazy-init="true">

<jpa:repositories base-package="org.kb" repository-impl-postfix="Impl">
<jpa:repository id="articleDao" repository-impl-ref="articleDaoPlus" /> 
</jpa:repositories>

但我得到了例外:

嵌套异常是 org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:发现以元素“jpa:repository”开头的无效内容。 '{"http://www.springframework.org/schema/data/repository":include-filter, "http://www.springframework.org/schema/data/repository":exclude-filter}' 之一是预计。

【问题讨论】:

标签: java spring spring-data-jpa


【解决方案1】:

简而言之,如果您将http://www.springframework.org/schema/data/jpa/spring-jpa.xsd 替换为http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd,它将解决问题。但我不确定你是否愿意这样做。

原因?标签 &lt;jpa:repository id="articleDao" repository-impl-ref="articleDaoPlus" /&gt; 在新的 spring-data-jpa 版本中被删除。

看看http://www.springframework.org/schema/data/jpa/spring-jpa.xsd和http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd这两个xsd之间的区别

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 2016-01-22
    • 2013-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多